Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(cursor): extrude Prism Glow's drawing instead of modelling it

Claude71d52b647c42
diff --git a/crates/compositor/src/compositor_linux.rs b/crates/compositor/src/compositor_linux.rs
index f772496b0..d6f14670f 100644
--- a/crates/compositor/src/compositor_linux.rs
+++ b/crates/compositor/src/compositor_linux.rs
@@ -5697,7 +5697,7 @@ mod tests {
for state in ["arrow", "pointer"] {
let still = model_track(state, false, 0.5);
let sprite = compose_model(&comp, &blue, &extruded, &still);
- for theme in ["studio-ink", "prism-glow", "pop-coral", "pixel-candy", "star-sprout"] {
+ for theme in ["studio-ink", "pop-coral", "pixel-candy", "star-sprout"] {
// Le sprite reste celui du theme par defaut : seul le nom pose le modele.
let json = extruded
.replace(&format!(r#"/{state}.png","#), &format!(r#"/{state}.png","sculpt":"{theme}/{state}","#));
diff --git a/crates/compositor/src/sculpt.rs b/crates/compositor/src/sculpt.rs
index beec1a223..14f00148d 100644
--- a/crates/compositor/src/sculpt.rs
+++ b/crates/compositor/src/sculpt.rs
@@ -1,18 +1,17 @@
-//! Curseurs sculptés : la flèche et la main des cinq thèmes d'origine, modelées en volumes dans les
-//! shaders (mode 15, `sculpt_proto`) au lieu d'extruder leur PNG — capsules et unions lissées,
-//! extrusions arrondies, voxels, polyèdres taillés, pièces cerclées du trait de leur dessin (Star
-//! Sprout). Ce module en tient ce que la géométrie doit savoir côté CPU : l'identifiant que lit le
-//! shader, et la boîte du modèle (`SpriteShape`) qui pose le hotspot, règle la garde au sol et
-//! borne la boîte de dessin.
+//! Curseurs sculptés : la flèche et la main des thèmes d'origine, modelées en volumes dans les
+//! shaders (mode 15, `sculpt_proto`) au lieu d'extruder leur PNG — voxels (Pixel Candy), pièces
+//! cerclées du trait de leur dessin (Studio Ink, Pop Coral, Star Sprout). Prism Glow n'en a pas :
+//! son dessin à facettes est extrudé comme tout sprite. Ce module en tient ce que la géométrie
+//! doit savoir côté CPU : l'identifiant que lit le shader, et la boîte du modèle (`SpriteShape`)
+//! qui pose le hotspot, règle la garde au sol et borne la boîte de dessin.
//!
//! Les formes sont écrites dans le repère du PROTOTYPE où elles ont été dessinées : hauteur du
//! 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.
//!
-//! 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é.
+//! Les grilles de voxels de Pixel Candy sont des tables que
+//! `scripts/generate-pixel-candy-voxels.mjs` écrit dans les trois shaders : on change la grille
+//! dans le script, on le relance, et on ajuste ici la boîte si la forme a bougé.
use crate::frame_geometry::SpriteShape;
@@ -32,12 +31,9 @@ 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 du cristal, que son trait marine élargit et dont le pouce déborde ; des voxels, que leur
-/// anneau violet élargit d'une cellule ; puis des autres 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.09, 0.74, 0.03];
-const BOX_GEM_HAND: [f32; 3] = [-0.43, 0.63, 0.03];
+/// Celles 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 les calques (Pop Coral), le pouce.
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];
@@ -47,12 +43,12 @@ const BOX_CORAL_HAND: [f32; 3] = [-0.38, 0.62, 0.04];
const BOX_SPROUT_ARROW: [f32; 3] = [-0.08, 0.87, 0.03];
const BOX_SPROUT_HAND: [f32; 3] = [-0.33, 0.56, 0.03];
-/// Dans l'ordre des identifiants du shader.
+/// Dans l'ordre des identifiants du shader. Prism Glow y garde sa place, sans modèle.
const THEMES: [&str; 5] = ["studio-ink", "prism-glow", "pop-coral", "pixel-candy", "star-sprout"];
+const EXTRUDED: &str = "prism-glow";
/// Le haut de la silhouette (y du prototype) : l'anneau violet des voxels dépasse la pointe
-/// d'une cellule ; les thèmes cerclés, le cristal compris, tiennent leur hotspot au bord de leur
-/// trait, comme leur PNG.
+/// d'une cellule ; les thèmes cerclés tiennent leur hotspot au bord de leur trait, comme leur PNG.
fn silhouette_top(theme: usize, _arrow: bool) -> f32 {
if THEMES[theme] == "pixel-candy" { VOX } else { 0.0 }
}
@@ -62,8 +58,6 @@ fn model_box(theme: usize, arrow: bool) -> [f32; 3] {
match (THEMES[theme], arrow) {
("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,
@@ -75,10 +69,11 @@ fn model_box(theme: usize, arrow: bool) -> [f32; 3] {
}
/// Le curseur sculpté que nomme la scène (`"<thème>/<état>"`, cf. `resolveCursorSprites`), sous
-/// la forme que le mode 15 attend. `None` pour un nom inconnu : l'appelant extrude le sprite.
+/// la forme que le mode 15 attend. `None` pour un nom inconnu ou un thème sans modèle (Prism Glow,
+/// qu'un ancien projet peut encore nommer) : l'appelant extrude le sprite.
pub fn sculpted_shape(name: &str) -> Option<SpriteShape> {
let (theme, state) = name.split_once('/')?;
- let theme = THEMES.iter().position(|t| *t == theme)?;
+ let theme = THEMES.iter().position(|t| *t == theme && *t != EXTRUDED)?;
let arrow = match state {
"arrow" => true,
"pointer" => false,
@@ -119,14 +114,16 @@ mod tests {
#[test]
fn each_theme_arrow_and_hand_has_its_own_id_in_shader_order() {
for (k, name) in NAMES.iter().enumerate() {
- let shape = sculpted_shape(name).expect(name);
- assert_eq!(shape.sculpt, k as u32 + 1, "{name}");
+ match sculpted_shape(name) {
+ Some(shape) => assert_eq!(shape.sculpt, k as u32 + 1, "{name}"),
+ None => assert!(name.starts_with(EXTRUDED), "{name} : pas de modèle"),
+ }
}
}
#[test]
fn other_states_and_themes_keep_the_extruded_sprite() {
- for name in ["default/arrow", "pop-coral/text", "pop-coral", "", "pop-coral/arrow/x"] {
+ for name in ["default/arrow", "pop-coral/text", "pop-coral", "", "pop-coral/arrow/x", "prism-glow/arrow"] {
assert!(sculpted_shape(name).is_none(), "{name}");
}
}
@@ -135,7 +132,7 @@ mod tests {
/// une hauteur ; la boîte a la hauteur du sprite, son plus grand côté, comme le veut le mode 15.
#[test]
fn the_box_holds_the_hotspot_and_the_silhouette_top() {
- for name in NAMES {
+ for name in NAMES.into_iter().filter(|n| !n.starts_with(EXTRUDED)) {
let s = sculpted_shape(name).unwrap();
assert!((0.0..1.0).contains(&s.hotspot[0]) && (0.0..1.0).contains(&s.hotspot[1]), "{name}");
assert!(s.top <= s.hotspot[1] + 1e-6, "{name} : haut de silhouette sous le hotspot");
@@ -174,44 +171,6 @@ mod tests {
}
}
- /// Les tables de Prism Glow, que `scripts/generate-prism-glow-gem.mjs` écrit dans les trois
- /// shaders, y sont les mêmes ; chaque pièce a ses plans, aux normales unitaires, et un contour
- /// convexe qui tourne dans le sens trigonométrique, que suit le trait.
- #[test]
- fn the_gem_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");
- for name in ["GEM_PLANES", "GEM_PIECE", "GEM_BOX", "GEM_OUTLINE", "GEM_OUTLINE_N", "GEM_RIM"] {
- 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 starts = table(wgsl, "GEM_PIECE");
- assert_eq!(starts.len(), 9, "2 pièces de flèche, 6 de main");
- assert!(starts.windows(2).all(|w| w[1] >= w[0] + 4.0), "une pièce sans volume");
- let planes = table(wgsl, "GEM_PLANES");
- assert_eq!(planes.len(), starts[8] as usize * 4);
- for p in planes.chunks(4) {
- let len = (p[0] * p[0] + p[1] * p[1] + p[2] * p[2]).sqrt();
- assert!((len - 1.0).abs() < 1e-3, "normale non unitaire : {p:?}");
- }
- let outline = table(wgsl, "GEM_OUTLINE");
- let ends = table(wgsl, "GEM_OUTLINE_N");
- assert_eq!(ends.len(), 9);
- for w in ends.windows(2) {
- let piece = &outline[w[0] as usize * 2..w[1] as usize * 2];
- let v: Vec<[f32; 2]> = piece.chunks(2).map(|c| [c[0], c[1]]).collect();
- assert!(v.len() >= 3, "contour de moins de trois sommets");
- for i in 0..v.len() {
- let [a, b, c] = [v[i], v[(i + 1) % v.len()], v[(i + 2) % v.len()]];
- let turn = (b[0] - a[0]) * (c[1] - b[1]) - (b[1] - a[1]) * (c[0] - b[0]);
- assert!(turn > 0.0, "contour non convexe ou à rebours : {v:?}");
- }
- }
- }
-
/// 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> {
diff --git a/crates/compositor/src/shaders.hlsl b/crates/compositor/src/shaders.hlsl
index 339536523..7b15fec55 100644
--- a/crates/compositor/src/shaders.hlsl
+++ b/crates/compositor/src/shaders.hlsl
@@ -589,7 +589,8 @@ static const float MODEL_CONTACT_ALPHA = 0.5;
// 1 + 2 × thème + forme ; thèmes 0 Studio Ink, 1 Prism Glow, 2 Pop Coral, 3 Pixel Candy,
// 4 Star Sprout ; formes 0 flèche, 1 main. Id des matières : 1 corps, 2 bande, calque ou
// manchette, 3 tirets, calque corail ou étoile, 4 feuilles, 5 trait des thèmes cerclés (et
-// yeux), 6 face des voxels, 7 anneau violet, 8 pierre de Prism Glow.
+// yeux), 6 face des voxels, 7 anneau violet. Prism Glow n'a pas de modèle : son dessin est
+// extrudé, comme un sprite (id 0).
static const float SCULPT_SCALE = 0.85;
static const float SCULPT_HOVER = 0.05;
static const float SCULPT_VOX = 0.07;
@@ -1041,243 +1042,6 @@ float s_pixel_outline(float2 p, int shape)
return d;
}
-// Prism Glow : le dessin 2D, son trait marine et ses facettes en aplats, avec le volume d'une
-// pierre taillée. Chaque pièce est un polyèdre convexe, le max des plans de ses faces (normale
-// unitaire vers l'extérieur, décalage), et la gemme l'union de ses pièces. La flèche en a deux
-// (tête, queue) ; la main six (index, majeur, annulaire, auriculaire, pouce, paume) posées sur
-// une même dalle, les doigts plus hauts que la paume là où ils la chevauchent : leur pli avec elle
-// fait les jointures. Autour, le trait des thèmes cerclés, large de `GEM_RIM.x`, son jonc à la
-// hauteur `GEM_RIM.y`, qui suit le contour des pièces (`GEM_OUTLINE`, bornés par `GEM_OUTLINE_N`).
-// `GEM_PIECE` borne les plans de chaque pièce, `GEM_BOX` (centre, demi-côtés) la boîte de chaque
-// gemme. Tables générées par 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[194] = {
- float4(0.0000, 0.0000, -1.0000, -0.0500), float4(-1.0000, 0.0000, 0.0000, 0.0000),
- float4(0.6701, 0.7423, 0.0000, -0.0445), float4(0.3396, -0.9406, 0.0000, 0.8267),
- float4(-0.7433, 0.0000, 0.6690, 0.1003), float4(0.4981, 0.5517, 0.6690, 0.0672),
- float4(-0.5384, 0.0572, 0.8407, 0.1227), float4(0.3250, 0.4398, 0.8373, 0.0992),
- float4(0.2525, -0.6991, 0.6690, 0.7149), float4(-0.5707, -0.0558, 0.8192, 0.1719),
- float4(0.1274, -0.5495, 0.8257, 0.6069), float4(0.2498, -0.4933, 0.8332, 0.6051),
- float4(0.4180, 0.3846, 0.8230, 0.1463), float4(-0.4678, 0.0600, 0.8818, 0.1348),
- float4(0.2763, 0.3898, 0.8785, 0.1145), float4(-0.4428, -0.0609, 0.8945, 0.1991),
- float4(0.0034, -0.2407, 0.9706, 0.3843), float4(0.1463, -0.1729, 0.9740, 0.3795),
- float4(0.3348, 0.2853, 0.8981, 0.1791), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(-0.9247, -0.3807, 0.0000, 0.0845), float4(-0.2425, 0.9701, 0.0000, -0.7065),
- float4(0.3162, -0.9487, 0.0000, 1.0360), float4(0.9162, 0.4008, 0.0000, 0.1197),
- float4(-0.6992, -0.2879, 0.6544, 0.1621), float4(-0.1834, 0.7336, 0.6544, -0.4361),
- float4(-0.5935, -0.1579, 0.7892, 0.1137), float4(-0.2785, 0.5032, 0.8181, -0.2726),
- float4(0.2391, -0.7174, 0.6544, 0.8815), float4(-0.5432, -0.3092, 0.7806, 0.2512),
- float4(0.0499, -0.5957, 0.8016, 0.7239), float4(0.6928, 0.3031, 0.6544, 0.1887),
- float4(0.3144, -0.4913, 0.8123, 0.7383), float4(0.5918, 0.1680, 0.7884, 0.2788),
- float4(0.5372, 0.3248, 0.7784, 0.1307), float4(-0.0022, 0.6040, 0.7970, -0.2600),
- float4(-0.5197, -0.1213, 0.8457, 0.1169), float4(-0.2438, 0.2827, 0.9277, -0.0861),
- float4(-0.4593, -0.2814, 0.8425, 0.2657), float4(-0.0463, -0.3759, 0.9255, 0.5100),
- float4(0.2578, -0.2548, 0.9320, 0.5244), float4(0.5289, 0.1347, 0.8379, 0.2882),
- float4(0.4810, 0.3053, 0.8219, 0.1309), float4(0.0665, 0.4124, 0.9086, -0.0825),
- float4(0.0000, 0.0000, -1.0000, -0.0500), float4(0.0000, -1.0000, 0.0000, 0.7224),
- float4(-1.0000, 0.0000, 0.0000, 0.1288), float4(1.0000, 0.0000, 0.0000, 0.1288),
- float4(0.7682, 0.6402, 0.0000, 0.0075), float4(0.0000, 1.0000, 0.0000, -0.0600),
- float4(-0.7682, 0.6402, 0.0000, 0.0075), float4(0.0000, -0.8755, 0.4833, 0.7049),
- float4(-0.8755, 0.0000, 0.4833, 0.1853), float4(0.8755, 0.0000, 0.4833, 0.1853),
- float4(0.6934, 0.5778, 0.4306, 0.0714), float4(0.7205, 0.4859, 0.4948, 0.0976),
- float4(0.0000, 0.9239, 0.3825, 0.0019), float4(-0.6934, 0.5778, 0.4306, 0.0714),
- float4(-0.7205, 0.4859, 0.4948, 0.0976), float4(0.0000, -0.4966, 0.8680, 0.5186),
- float4(-0.7029, 0.0000, 0.7113, 0.2134), float4(0.7029, 0.0000, 0.7113, 0.2134),
- float4(0.6092, 0.0477, 0.7916, 0.2127), float4(-0.6092, 0.0477, 0.7916, 0.2127),
- float4(0.0000, 0.1186, 0.9929, 0.2362), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(0.0000, -1.0000, 0.0000, 0.6856), float4(-1.0000, 0.0000, 0.0000, -0.1104),
- float4(1.0000, 0.0000, 0.0000, 0.2668), float4(0.7809, 0.6247, 0.0000, -0.0246),
- float4(0.0000, 1.0000, 0.0000, -0.3268), float4(-0.7071, 0.7071, 0.0000, -0.3352),
- float4(0.0000, -0.8357, 0.5492, 0.6553), float4(-0.8478, 0.0000, 0.5304, -0.0140),
- float4(-0.7734, -0.1600, 0.6134, 0.1163), float4(0.8478, 0.0000, 0.5304, 0.3057),
- float4(0.7734, -0.1600, 0.6134, 0.4081), float4(0.6526, 0.5221, 0.5492, 0.0619),
- float4(0.8337, 0.0180, 0.5520, 0.2985), float4(0.0000, 0.8451, 0.5345, -0.1960),
- float4(0.0998, 0.8168, 0.5683, -0.1587), float4(-0.5909, 0.5909, 0.5492, -0.1977),
- float4(-0.0826, 0.8224, 0.5629, -0.1965), float4(-0.8334, 0.0176, 0.5524, -0.0155),
- float4(0.0000, -0.7549, 0.6559, 0.6215), float4(0.5776, 0.4621, 0.6729, 0.0893),
- float4(0.6294, 0.1651, 0.7593, 0.2311), float4(-0.5166, 0.5166, 0.6828, -0.1354),
- float4(-0.6151, 0.1675, 0.7704, -0.0020), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(0.0000, -1.0000, 0.0000, 0.6856), float4(-1.0000, 0.0000, 0.0000, -0.2484),
- float4(1.0000, 0.0000, 0.0000, 0.4048), float4(0.7809, 0.6247, 0.0000, 0.0516),
- float4(0.0000, 1.0000, 0.0000, -0.3774), float4(-0.7071, 0.7071, 0.0000, -0.4685),
- float4(0.0000, -0.8357, 0.5492, 0.6553), float4(-0.8378, 0.0000, 0.5460, -0.1262),
- float4(-0.7868, -0.1311, 0.6032, -0.0151), float4(0.8378, 0.0000, 0.5460, 0.4210),
- float4(0.7868, -0.1311, 0.6032, 0.4989), float4(0.6526, 0.5221, 0.5492, 0.1255),
- float4(0.8353, 0.0036, 0.5498, 0.4191), float4(0.0000, 0.8451, 0.5345, -0.2388),
- float4(0.0998, 0.8168, 0.5683, -0.1863), float4(-0.5909, 0.5909, 0.5492, -0.3092),
- float4(-0.0826, 0.8224, 0.5629, -0.2495), float4(-0.8353, 0.0035, 0.5498, -0.1265),
- float4(0.0000, -0.8179, 0.5754, 0.6484), float4(0.5776, 0.4621, 0.6729, 0.1456),
- float4(0.6288, 0.1734, 0.7580, 0.3055), float4(-0.5166, 0.5166, 0.6828, -0.2328),
- float4(-0.6138, 0.1761, 0.7696, -0.0988), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(0.0000, -1.0000, 0.0000, 0.7040), float4(-1.0000, 0.0000, 0.0000, -0.3864),
- float4(1.0000, 0.0000, 0.0000, 0.5382), float4(0.7809, 0.6247, 0.0000, 0.1242),
- float4(0.0000, 1.0000, 0.0000, -0.4280), float4(-0.7071, 0.7071, 0.0000, -0.6019),
- float4(0.0000, -0.8357, 0.5492, 0.6707), float4(-0.8423, 0.0000, 0.5391, -0.2446),
- float4(-0.7508, -0.2048, 0.6280, -0.0518), float4(0.8357, 0.0000, 0.5492, 0.5322),
- float4(0.6526, 0.5221, 0.5492, 0.1861), float4(0.0000, 0.8451, 0.5345, -0.2815),
- float4(0.0998, 0.8168, 0.5683, -0.2143), float4(-0.5909, 0.5909, 0.5492, -0.4206),
- float4(-0.1072, 0.8172, 0.5662, -0.3102), float4(-0.8340, 0.0131, 0.5516, -0.2456),
- float4(0.0000, -0.8010, 0.5987, 0.6562), float4(0.8231, 0.0000, 0.5679, 0.5291),
- float4(0.5776, 0.4621, 0.6729, 0.1993), float4(0.6279, 0.1855, 0.7559, 0.3739),
- float4(-0.5355, 0.5355, 0.6530, -0.3524), float4(-0.6448, 0.1822, 0.7423, -0.2131),
- float4(0.0000, 0.0000, -1.0000, -0.0500), float4(-0.6163, -0.7875, 0.0000, 0.7006),
- float4(-0.9985, -0.0555, 0.0000, 0.3657), float4(0.9950, -0.0995, 0.0000, -0.0398),
- float4(0.7926, 0.6097, 0.0000, -0.3900), float4(0.0000, 1.0000, 0.0000, -0.4004),
- float4(-0.7593, 0.6508, 0.0000, -0.0440), float4(-0.5073, -0.6482, 0.5679, 0.6618),
- float4(-0.8611, -0.0478, 0.5061, 0.3913), float4(-0.7393, -0.3013, 0.6022, 0.5251),
- float4(0.8405, -0.0840, 0.5353, 0.0467), float4(0.5328, -0.3560, 0.7677, 0.3348),
- float4(0.6524, 0.5018, 0.5679, -0.2358), float4(0.8129, 0.0099, 0.5823, 0.0074),
- float4(0.0000, 0.8231, 0.5679, -0.2444), float4(-0.6249, 0.5357, 0.5679, 0.0489),
- float4(-0.8088, 0.0631, 0.5847, 0.3337), float4(-0.4667, -0.5964, 0.6531, 0.6337),
- float4(-0.4922, -0.5381, 0.6842, 0.6115), float4(0.6153, 0.4733, 0.6303, -0.2044),
- float4(0.6249, 0.3006, 0.7206, -0.0972), float4(0.0000, 0.7790, 0.6271, -0.2143),
- float4(-0.5567, 0.4772, 0.6799, 0.0767), float4(-0.6567, 0.2139, 0.7232, 0.2410),
- float4(-0.3316, -0.0488, 0.9422, 0.3547), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(-0.8384, -0.5450, 0.0000, 0.5958), float4(-0.4138, 0.9104, 0.0000, -0.4277),
- float4(0.0000, -1.0000, 0.0000, 0.9800), float4(0.7853, -0.6192, 0.0000, 0.8813),
- float4(1.0000, 0.0000, 0.0000, 0.5382), float4(0.0566, 0.9984, 0.0000, -0.5254),
- float4(-0.7112, -0.4623, 0.5297, 0.5848), float4(-0.3032, 0.6670, 0.6806, -0.2113),
- float4(-0.4105, 0.3857, 0.8263, 0.0163), float4(-0.4507, 0.2882, 0.8449, 0.0914),
- float4(0.0000, -0.6993, 0.7148, 0.7925), float4(-0.0624, -0.6620, 0.7469, 0.7654),
- float4(-0.4608, -0.4581, 0.7601, 0.5969), float4(0.6592, -0.5198, 0.5434, 0.8214),
- float4(0.0113, -0.6787, 0.7344, 0.7792), float4(0.3396, -0.5477, 0.7646, 0.7702),
- float4(0.7207, 0.0000, 0.6932, 0.4919), float4(0.6182, -0.2793, 0.7347, 0.6498),
- float4(0.0449, 0.7917, 0.6092, -0.3253), float4(0.1069, 0.6384, 0.7622, -0.1836),
- float4(0.4599, 0.3272, 0.8255, 0.1892), float4(-0.4252, 0.3195, 0.8468, 0.0653),
- float4(-0.3146, -0.4157, 0.8534, 0.5652), float4(0.0252, -0.6408, 0.7673, 0.7539),
- float4(0.1792, -0.5010, 0.8467, 0.6871), float4(0.1111, 0.6228, 0.7744, -0.1701),
- float4(0.1536, 0.5517, 0.8198, -0.0987), float4(0.0165, -0.1450, 0.9893, 0.3889),
- float4(-0.0842, -0.2545, 0.9634, 0.4549), float4(-0.1798, -0.2748, 0.9446, 0.4657),
- float4(0.1433, -0.1696, 0.9750, 0.4318), float4(0.1693, -0.2060, 0.9638, 0.4650)
-};
-static const int GEM_PIECE[9] = { 0, 19, 44, 65, 89, 113, 136, 161, 194 };
-static const float3 GEM_BOX[4] = {
- float3(0.324, -0.524, 0.165),
- float3(0.334, 0.474, 0.125),
- float3(0.099, -0.520, 0.175),
- float3(0.449, 0.470, 0.135)
-};
-static const float2 GEM_OUTLINE[43] = {
- float2(0.0000, -0.0600), float2(0.0000, -0.8790), float2(0.6480, -0.6450), float2(0.1890, -0.6810),
- float2(0.3150, -0.9870), float2(0.5310, -0.9150), float2(0.4050, -0.6270), float2(-0.1288, -0.7224),
- float2(0.1288, -0.7224), float2(0.1288, -0.1428), float2(0.0598, -0.0600), float2(-0.0598, -0.0600),
- float2(-0.1288, -0.1428), float2(0.1104, -0.6856), float2(0.2668, -0.6856), float2(0.2668, -0.3728),
- float2(0.2300, -0.3268), float2(0.1472, -0.3268), float2(0.1104, -0.3636), float2(0.2484, -0.6856),
- float2(0.4048, -0.6856), float2(0.4048, -0.4234), float2(0.3680, -0.3774), float2(0.2852, -0.3774),
- float2(0.2484, -0.4142), float2(0.3864, -0.7040), float2(0.5382, -0.7040), float2(0.5382, -0.4740),
- float2(0.5014, -0.4280), float2(0.4232, -0.4280), float2(0.3864, -0.4648), float2(-0.3312, -0.6304),
- float2(-0.1196, -0.7960), float2(-0.0920, -0.5200), float2(-0.1840, -0.4004), float2(-0.2852, -0.4004),
- float2(-0.3404, -0.4648), float2(-0.3128, -0.6120), float2(-0.0736, -0.9800), float2(0.3496, -0.9800),
- float2(0.5382, -0.7408), float2(0.5382, -0.5568), float2(-0.1104, -0.5200)
-};
-static const int GEM_OUTLINE_N[9] = { 0, 3, 7, 13, 19, 25, 31, 37, 43 };
-static const float2 GEM_RIM = float2(0.060, 0.150);
-// </prism-glow-gem>
-
-// Hors de sa boîte, la distance à la boîte : une borne sûre, et les plans ne sont lus que près du
-// modèle.
-float s_gem_cut(float3 p, int shape)
-{
- float far = length(max(abs(p - GEM_BOX[2 * shape]) - GEM_BOX[2 * shape + 1], 0.0));
- if (far > 0.05)
- {
- return far;
- }
- float d = 1e9;
- [loop] for (int k = shape == 0 ? 0 : 2; k < (shape == 0 ? 2 : 8); k++)
- {
- float e = -1e9;
- [loop] for (int i = GEM_PIECE[k]; i < GEM_PIECE[k + 1]; i++)
- {
- e = max(e, dot(p, GEM_PLANES[i].xyz) - GEM_PLANES[i].w);
- }
- d = min(d, e);
- }
- return d;
-}
-
-// Distance signée, dans le plan de l'écran, au contour des pièces : dans une pièce convexe, la
-// plus haute de ses arêtes ; dehors, la plus proche.
-float s_gem_sil(float2 p, int shape)
-{
- float d = 1e9;
- [loop] for (int k = shape == 0 ? 0 : 2; k < (shape == 0 ? 2 : 8); k++)
- {
- int a0 = GEM_OUTLINE_N[k];
- int n = GEM_OUTLINE_N[k + 1] - a0;
- float inside = -1e9;
- float outside = 1e9;
- [loop] for (int i = 0; i < n; i++)
- {
- float2 a = GEM_OUTLINE[a0 + i];
- float2 e = GEM_OUTLINE[a0 + (i + 1) % n] - a;
- float2 w = p - a;
- inside = max(inside, (w.x * e.y - w.y * e.x) / length(e));
- outside = min(outside, length(w - e * saturate(dot(w, e) / dot(e, e))));
- }
- d = min(d, inside <= 0.0 ? inside : outside);
- }
- return d;
-}
-
-// La gemme dans son trait : le plateau et le jonc marine (matière 5) de `s_piece`, la pierre
-// (matière 8) à la place du coussin.
-float2 s_gem_model(float3 p, int shape)
-{
- float sil = s_gem_sil(p.xy, shape);
- float w = GEM_RIM.x;
- float zt = GEM_RIM.y;
- float tray = s_extrude(sil - w, p.z - 0.5 * (SCULPT_HOVER + zt), 0.5 * (zt - SCULPT_HOVER), 0.012);
- float bead = length(float2(sil - 0.5 * w, p.z - zt)) - 0.5 * w;
- return s_opu(float2(min(tray, bead), 5.0), float2(s_gem_cut(p, shape), 8.0));
-}
-
-// La normale de la facette qui porte `p` : dans la pièce touchée (la plus basse des distances), le
-// plan le plus haut. Exacte et la même sur toute la facette, d'où ses aplats.
-float3 s_gem_facet(float3 p, int shape)
-{
- float best = 1e9;
- float3 n = float3(0.0, 0.0, 1.0);
- [loop] for (int k = shape == 0 ? 0 : 2; k < (shape == 0 ? 2 : 8); k++)
- {
- float e1 = -1e9;
- float3 n1 = float3(0.0, 0.0, 1.0);
- [loop] for (int i = GEM_PIECE[k]; i < GEM_PIECE[k + 1]; i++)
- {
- float e = dot(p, GEM_PLANES[i].xyz) - GEM_PLANES[i].w;
- if (e > e1)
- {
- e1 = e;
- n1 = GEM_PLANES[i].xyz;
- }
- }
- if (e1 < best)
- {
- best = e1;
- n = n1;
- }
- }
- return n;
-}
-
-// Les teintes du dessin, selon où regarde la facette (par huitième de tour depuis la droite, y vers
-// le haut) : bleu, violet, violet clair, cyan pâle, cyan, azur, bleu profond, bleu. Une facette à
-// plat prend l'azur du milieu du dessin.
-static const float3 GEM_HUES[8] = {
- float3(0.08, 0.26, 0.96), float3(0.70, 0.30, 1.0), float3(0.58, 0.40, 1.0), float3(0.62, 0.97, 1.0),
- float3(0.0, 0.92, 1.0), float3(0.02, 0.58, 1.0), float3(0.05, 0.14, 0.70), float3(0.06, 0.20, 0.86)
-};
-
-float3 s_gem_colour(float3 n)
-{
- float a = atan2(n.y, n.x) / 0.7853982 + 8.0;
- int i = (int)floor(a) % 8;
- float3 hue = lerp(GEM_HUES[i], GEM_HUES[(i + 1) % 8], a - floor(a));
- float3 c = lerp(float3(0.06, 0.45, 1.0), hue, smoothstep(0.03, 0.25, length(n.xy)));
- return pow(c, 2.2);
-}
-
// Le modèle `shape` du thème `theme`, repère du prototype : (distance, id de matière).
float2 sculpt_proto(float3 p, int theme, int shape)
{
@@ -1285,10 +1049,6 @@ float2 sculpt_proto(float3 p, int theme, int shape)
{
return s_voxels(p, shape);
}
- if (theme == 1)
- {
- return s_gem_model(p, shape);
- }
// Un seul appel pour les trois thèmes cerclés et leurs deux formes (FXC recopie chaque appel).
return s_rimmed(p, theme, shape);
}
@@ -1310,17 +1070,17 @@ float sculpt_units()
// Le curseur sculpté en `q` (repère du modèle) : distance et id de matière. `occ` : ce qui porte
// l'ombre sur l'écran. La borne des plans d'une gemme et le champ des voxels sont de mauvaises
// distances loin de la surface : la pénombre s'y strie, ou s'arrête net au bord de la boîte des
-// voxels. Prism Glow et Pixel Candy portent donc l'ombre de leur contour, extrudé sur la hauteur
-// des voxels : le bord extérieur du trait marine, la face et l'anneau violet.
+// voxels. Pixel Candy porte donc l'ombre de son contour, la face et l'anneau violet, extrudé sur
+// la hauteur des voxels.
float2 sculpt_eval(float3 q, bool occ)
{
int id = sculpt_id() - 1;
int theme = id / 2, shape = id % 2;
float3 p = sculpt_point(q);
float2 r;
- if (occ && (theme == 1 || theme == 3))
+ if (occ && theme == 3)
{
- float d2 = theme == 1 ? s_gem_sil(p.xy, shape) - GEM_RIM.x : s_pixel_outline(p.xy, shape);
+ 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);
}
@@ -1470,12 +1230,6 @@ SculptMat sculpt_material(float mat, float3 p, int theme, int shape)
if (mat < 2.5) return s_mat(s_lin(0.95, 0.92, 0.85), 0.3, 0.6, 0.35, 0.25);
return s_mat(s_lin(0.1, 0.1, 0.11), 0.55, 0.05, 0.0, 0.1);
}
- if (theme == 1)
- {
- // Le trait marine, mat ; la pierre, aux teintes de sa facette.
- if (mat < 6.5) return s_mat(s_lin(0.06, 0.07, 0.30), 0.7, 0.12, 0.05, 0.06);
- return s_mat(s_gem_colour(s_gem_facet(p, shape)), 0.3, 0.55, 0.25, 0.2);
- }
if (theme == 2)
{
// Corail : la flèche, le calque et les tirets de la main ; jaune : le gant, le calque et les
diff --git a/crates/compositor/src/shaders.metal b/crates/compositor/src/shaders.metal
index 3f64c3119..7805a5619 100644
--- a/crates/compositor/src/shaders.metal
+++ b/crates/compositor/src/shaders.metal
@@ -975,233 +975,12 @@ static float s_pixel_outline(float2 p, int shape)
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[194] = {
- float4(0.0000, 0.0000, -1.0000, -0.0500), float4(-1.0000, 0.0000, 0.0000, 0.0000),
- float4(0.6701, 0.7423, 0.0000, -0.0445), float4(0.3396, -0.9406, 0.0000, 0.8267),
- float4(-0.7433, 0.0000, 0.6690, 0.1003), float4(0.4981, 0.5517, 0.6690, 0.0672),
- float4(-0.5384, 0.0572, 0.8407, 0.1227), float4(0.3250, 0.4398, 0.8373, 0.0992),
- float4(0.2525, -0.6991, 0.6690, 0.7149), float4(-0.5707, -0.0558, 0.8192, 0.1719),
- float4(0.1274, -0.5495, 0.8257, 0.6069), float4(0.2498, -0.4933, 0.8332, 0.6051),
- float4(0.4180, 0.3846, 0.8230, 0.1463), float4(-0.4678, 0.0600, 0.8818, 0.1348),
- float4(0.2763, 0.3898, 0.8785, 0.1145), float4(-0.4428, -0.0609, 0.8945, 0.1991),
- float4(0.0034, -0.2407, 0.9706, 0.3843), float4(0.1463, -0.1729, 0.9740, 0.3795),
- float4(0.3348, 0.2853, 0.8981, 0.1791), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(-0.9247, -0.3807, 0.0000, 0.0845), float4(-0.2425, 0.9701, 0.0000, -0.7065),
- float4(0.3162, -0.9487, 0.0000, 1.0360), float4(0.9162, 0.4008, 0.0000, 0.1197),
- float4(-0.6992, -0.2879, 0.6544, 0.1621), float4(-0.1834, 0.7336, 0.6544, -0.4361),
- float4(-0.5935, -0.1579, 0.7892, 0.1137), float4(-0.2785, 0.5032, 0.8181, -0.2726),
- float4(0.2391, -0.7174, 0.6544, 0.8815), float4(-0.5432, -0.3092, 0.7806, 0.2512),
- float4(0.0499, -0.5957, 0.8016, 0.7239), float4(0.6928, 0.3031, 0.6544, 0.1887),
- float4(0.3144, -0.4913, 0.8123, 0.7383), float4(0.5918, 0.1680, 0.7884, 0.2788),
- float4(0.5372, 0.3248, 0.7784, 0.1307), float4(-0.0022, 0.6040, 0.7970, -0.2600),
- float4(-0.5197, -0.1213, 0.8457, 0.1169), float4(-0.2438, 0.2827, 0.9277, -0.0861),
- float4(-0.4593, -0.2814, 0.8425, 0.2657), float4(-0.0463, -0.3759, 0.9255, 0.5100),
- float4(0.2578, -0.2548, 0.9320, 0.5244), float4(0.5289, 0.1347, 0.8379, 0.2882),
- float4(0.4810, 0.3053, 0.8219, 0.1309), float4(0.0665, 0.4124, 0.9086, -0.0825),
- float4(0.0000, 0.0000, -1.0000, -0.0500), float4(0.0000, -1.0000, 0.0000, 0.7224),
- float4(-1.0000, 0.0000, 0.0000, 0.1288), float4(1.0000, 0.0000, 0.0000, 0.1288),
- float4(0.7682, 0.6402, 0.0000, 0.0075), float4(0.0000, 1.0000, 0.0000, -0.0600),
- float4(-0.7682, 0.6402, 0.0000, 0.0075), float4(0.0000, -0.8755, 0.4833, 0.7049),
- float4(-0.8755, 0.0000, 0.4833, 0.1853), float4(0.8755, 0.0000, 0.4833, 0.1853),
- float4(0.6934, 0.5778, 0.4306, 0.0714), float4(0.7205, 0.4859, 0.4948, 0.0976),
- float4(0.0000, 0.9239, 0.3825, 0.0019), float4(-0.6934, 0.5778, 0.4306, 0.0714),
- float4(-0.7205, 0.4859, 0.4948, 0.0976), float4(0.0000, -0.4966, 0.8680, 0.5186),
- float4(-0.7029, 0.0000, 0.7113, 0.2134), float4(0.7029, 0.0000, 0.7113, 0.2134),
- float4(0.6092, 0.0477, 0.7916, 0.2127), float4(-0.6092, 0.0477, 0.7916, 0.2127),
- float4(0.0000, 0.1186, 0.9929, 0.2362), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(0.0000, -1.0000, 0.0000, 0.6856), float4(-1.0000, 0.0000, 0.0000, -0.1104),
- float4(1.0000, 0.0000, 0.0000, 0.2668), float4(0.7809, 0.6247, 0.0000, -0.0246),
- float4(0.0000, 1.0000, 0.0000, -0.3268), float4(-0.7071, 0.7071, 0.0000, -0.3352),
- float4(0.0000, -0.8357, 0.5492, 0.6553), float4(-0.8478, 0.0000, 0.5304, -0.0140),
- float4(-0.7734, -0.1600, 0.6134, 0.1163), float4(0.8478, 0.0000, 0.5304, 0.3057),
- float4(0.7734, -0.1600, 0.6134, 0.4081), float4(0.6526, 0.5221, 0.5492, 0.0619),
- float4(0.8337, 0.0180, 0.5520, 0.2985), float4(0.0000, 0.8451, 0.5345, -0.1960),
- float4(0.0998, 0.8168, 0.5683, -0.1587), float4(-0.5909, 0.5909, 0.5492, -0.1977),
- float4(-0.0826, 0.8224, 0.5629, -0.1965), float4(-0.8334, 0.0176, 0.5524, -0.0155),
- float4(0.0000, -0.7549, 0.6559, 0.6215), float4(0.5776, 0.4621, 0.6729, 0.0893),
- float4(0.6294, 0.1651, 0.7593, 0.2311), float4(-0.5166, 0.5166, 0.6828, -0.1354),
- float4(-0.6151, 0.1675, 0.7704, -0.0020), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(0.0000, -1.0000, 0.0000, 0.6856), float4(-1.0000, 0.0000, 0.0000, -0.2484),
- float4(1.0000, 0.0000, 0.0000, 0.4048), float4(0.7809, 0.6247, 0.0000, 0.0516),
- float4(0.0000, 1.0000, 0.0000, -0.3774), float4(-0.7071, 0.7071, 0.0000, -0.4685),
- float4(0.0000, -0.8357, 0.5492, 0.6553), float4(-0.8378, 0.0000, 0.5460, -0.1262),
- float4(-0.7868, -0.1311, 0.6032, -0.0151), float4(0.8378, 0.0000, 0.5460, 0.4210),
- float4(0.7868, -0.1311, 0.6032, 0.4989), float4(0.6526, 0.5221, 0.5492, 0.1255),
- float4(0.8353, 0.0036, 0.5498, 0.4191), float4(0.0000, 0.8451, 0.5345, -0.2388),
- float4(0.0998, 0.8168, 0.5683, -0.1863), float4(-0.5909, 0.5909, 0.5492, -0.3092),
- float4(-0.0826, 0.8224, 0.5629, -0.2495), float4(-0.8353, 0.0035, 0.5498, -0.1265),
- float4(0.0000, -0.8179, 0.5754, 0.6484), float4(0.5776, 0.4621, 0.6729, 0.1456),
- float4(0.6288, 0.1734, 0.7580, 0.3055), float4(-0.5166, 0.5166, 0.6828, -0.2328),
- float4(-0.6138, 0.1761, 0.7696, -0.0988), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(0.0000, -1.0000, 0.0000, 0.7040), float4(-1.0000, 0.0000, 0.0000, -0.3864),
- float4(1.0000, 0.0000, 0.0000, 0.5382), float4(0.7809, 0.6247, 0.0000, 0.1242),
- float4(0.0000, 1.0000, 0.0000, -0.4280), float4(-0.7071, 0.7071, 0.0000, -0.6019),
- float4(0.0000, -0.8357, 0.5492, 0.6707), float4(-0.8423, 0.0000, 0.5391, -0.2446),
- float4(-0.7508, -0.2048, 0.6280, -0.0518), float4(0.8357, 0.0000, 0.5492, 0.5322),
- float4(0.6526, 0.5221, 0.5492, 0.1861), float4(0.0000, 0.8451, 0.5345, -0.2815),
- float4(0.0998, 0.8168, 0.5683, -0.2143), float4(-0.5909, 0.5909, 0.5492, -0.4206),
- float4(-0.1072, 0.8172, 0.5662, -0.3102), float4(-0.8340, 0.0131, 0.5516, -0.2456),
- float4(0.0000, -0.8010, 0.5987, 0.6562), float4(0.8231, 0.0000, 0.5679, 0.5291),
- float4(0.5776, 0.4621, 0.6729, 0.1993), float4(0.6279, 0.1855, 0.7559, 0.3739),
- float4(-0.5355, 0.5355, 0.6530, -0.3524), float4(-0.6448, 0.1822, 0.7423, -0.2131),
- float4(0.0000, 0.0000, -1.0000, -0.0500), float4(-0.6163, -0.7875, 0.0000, 0.7006),
- float4(-0.9985, -0.0555, 0.0000, 0.3657), float4(0.9950, -0.0995, 0.0000, -0.0398),
- float4(0.7926, 0.6097, 0.0000, -0.3900), float4(0.0000, 1.0000, 0.0000, -0.4004),
- float4(-0.7593, 0.6508, 0.0000, -0.0440), float4(-0.5073, -0.6482, 0.5679, 0.6618),
- float4(-0.8611, -0.0478, 0.5061, 0.3913), float4(-0.7393, -0.3013, 0.6022, 0.5251),
- float4(0.8405, -0.0840, 0.5353, 0.0467), float4(0.5328, -0.3560, 0.7677, 0.3348),
- float4(0.6524, 0.5018, 0.5679, -0.2358), float4(0.8129, 0.0099, 0.5823, 0.0074),
- float4(0.0000, 0.8231, 0.5679, -0.2444), float4(-0.6249, 0.5357, 0.5679, 0.0489),
- float4(-0.8088, 0.0631, 0.5847, 0.3337), float4(-0.4667, -0.5964, 0.6531, 0.6337),
- float4(-0.4922, -0.5381, 0.6842, 0.6115), float4(0.6153, 0.4733, 0.6303, -0.2044),
- float4(0.6249, 0.3006, 0.7206, -0.0972), float4(0.0000, 0.7790, 0.6271, -0.2143),
- float4(-0.5567, 0.4772, 0.6799, 0.0767), float4(-0.6567, 0.2139, 0.7232, 0.2410),
- float4(-0.3316, -0.0488, 0.9422, 0.3547), float4(0.0000, 0.0000, -1.0000, -0.0500),
- float4(-0.8384, -0.5450, 0.0000, 0.5958), float4(-0.4138, 0.9104, 0.0000, -0.4277),
- float4(0.0000, -1.0000, 0.0000, 0.9800), float4(0.7853, -0.6192, 0.0000, 0.8813),
- float4(1.0000, 0.0000, 0.0000, 0.5382), float4(0.0566, 0.9984, 0.0000, -0.5254),
- float4(-0.7112, -0.4623, 0.5297, 0.5848), float4(-0.3032, 0.6670, 0.6806, -0.2113),
- float4(-0.4105, 0.3857, 0.8263, 0.0163), float4(-0.4507, 0.2882, 0.8449, 0.0914),
- float4(0.0000, -0.6993, 0.7148, 0.7925), float4(-0.0624, -0.6620, 0.7469, 0.7654),
- float4(-0.4608, -0.4581, 0.7601, 0.5969), float4(0.6592, -0.5198, 0.5434, 0.8214),
- float4(0.0113, -0.6787, 0.7344, 0.7792), float4(0.3396, -0.5477, 0.7646, 0.7702),
- float4(0.7207, 0.0000, 0.6932, 0.4919), float4(0.6182, -0.2793, 0.7347, 0.6498),
- float4(0.0449, 0.7917, 0.6092, -0.3253), float4(0.1069, 0.6384, 0.7622, -0.1836),
- float4(0.4599, 0.3272, 0.8255, 0.1892), float4(-0.4252, 0.3195, 0.8468, 0.0653),
- float4(-0.3146, -0.4157, 0.8534, 0.5652), float4(0.0252, -0.6408, 0.7673, 0.7539),
- float4(0.1792, -0.5010, 0.8467, 0.6871), float4(0.1111, 0.6228, 0.7744, -0.1701),
- float4(0.1536, 0.5517, 0.8198, -0.0987), float4(0.0165, -0.1450, 0.9893, 0.3889),
- float4(-0.0842, -0.2545, 0.9634, 0.4549), float4(-0.1798, -0.2748, 0.9446, 0.4657),
- float4(0.1433, -0.1696, 0.9750, 0.4318), float4(0.1693, -0.2060, 0.9638, 0.4650)
-};
-constant int GEM_PIECE[9] = { 0, 19, 44, 65, 89, 113, 136, 161, 194 };
-constant float3 GEM_BOX[4] = {
- float3(0.324, -0.524, 0.165),
- float3(0.334, 0.474, 0.125),
- float3(0.099, -0.520, 0.175),
- float3(0.449, 0.470, 0.135)
-};
-constant float2 GEM_OUTLINE[43] = {
- float2(0.0000, -0.0600), float2(0.0000, -0.8790), float2(0.6480, -0.6450), float2(0.1890, -0.6810),
- float2(0.3150, -0.9870), float2(0.5310, -0.9150), float2(0.4050, -0.6270), float2(-0.1288, -0.7224),
- float2(0.1288, -0.7224), float2(0.1288, -0.1428), float2(0.0598, -0.0600), float2(-0.0598, -0.0600),
- float2(-0.1288, -0.1428), float2(0.1104, -0.6856), float2(0.2668, -0.6856), float2(0.2668, -0.3728),
- float2(0.2300, -0.3268), float2(0.1472, -0.3268), float2(0.1104, -0.3636), float2(0.2484, -0.6856),
- float2(0.4048, -0.6856), float2(0.4048, -0.4234), float2(0.3680, -0.3774), float2(0.2852, -0.3774),
- float2(0.2484, -0.4142), float2(0.3864, -0.7040), float2(0.5382, -0.7040), float2(0.5382, -0.4740),
- float2(0.5014, -0.4280), float2(0.4232, -0.4280), float2(0.3864, -0.4648), float2(-0.3312, -0.6304),
- float2(-0.1196, -0.7960), float2(-0.0920, -0.5200), float2(-0.1840, -0.4004), float2(-0.2852, -0.4004),
- float2(-0.3404, -0.4648), float2(-0.3128, -0.6120), float2(-0.0736, -0.9800), float2(0.3496, -0.9800),
- float2(0.5382, -0.7408), float2(0.5382, -0.5568), float2(-0.1104, -0.5200)
-};
-constant int GEM_OUTLINE_N[9] = { 0, 3, 7, 13, 19, 25, 31, 37, 43 };
-constant float2 GEM_RIM = float2(0.060, 0.150);
-// </prism-glow-gem>
-
-static float s_gem_cut(float3 p, int shape)
-{
- float far = length(max(abs(p - GEM_BOX[2 * shape]) - GEM_BOX[2 * shape + 1], 0.0));
- if (far > 0.05)
- {
- return far;
- }
- float d = 1e9;
- for (int k = shape == 0 ? 0 : 2; k < (shape == 0 ? 2 : 8); k++)
- {
- float e = -1e9;
- for (int i = GEM_PIECE[k]; i < GEM_PIECE[k + 1]; i++)
- {
- e = max(e, dot(p, GEM_PLANES[i].xyz) - GEM_PLANES[i].w);
- }
- d = min(d, e);
- }
- return d;
-}
-
-static float s_gem_sil(float2 p, int shape)
-{
- float d = 1e9;
- for (int k = shape == 0 ? 0 : 2; k < (shape == 0 ? 2 : 8); k++)
- {
- int a0 = GEM_OUTLINE_N[k];
- int n = GEM_OUTLINE_N[k + 1] - a0;
- float inside = -1e9;
- float outside = 1e9;
- for (int i = 0; i < n; i++)
- {
- float2 a = GEM_OUTLINE[a0 + i];
- float2 e = GEM_OUTLINE[a0 + (i + 1) % n] - a;
- float2 w = p - a;
- inside = max(inside, (w.x * e.y - w.y * e.x) / length(e));
- outside = min(outside, length(w - e * saturate(dot(w, e) / dot(e, e))));
- }
- d = min(d, inside <= 0.0 ? inside : outside);
- }
- return d;
-}
-
-static float2 s_gem_model(float3 p, int shape)
-{
- float sil = s_gem_sil(p.xy, shape);
- float w = GEM_RIM.x;
- float zt = GEM_RIM.y;
- float tray = s_extrude(sil - w, p.z - 0.5 * (SCULPT_HOVER + zt), 0.5 * (zt - SCULPT_HOVER), 0.012);
- float bead = length(float2(sil - 0.5 * w, p.z - zt)) - 0.5 * w;
- return s_opu(float2(min(tray, bead), 5.0), float2(s_gem_cut(p, shape), 8.0));
-}
-
-static float3 s_gem_facet(float3 p, int shape)
-{
- float best = 1e9;
- float3 n = float3(0.0, 0.0, 1.0);
- for (int k = shape == 0 ? 0 : 2; k < (shape == 0 ? 2 : 8); k++)
- {
- float e1 = -1e9;
- float3 n1 = float3(0.0, 0.0, 1.0);
- for (int i = GEM_PIECE[k]; i < GEM_PIECE[k + 1]; i++)
- {
- float e = dot(p, GEM_PLANES[i].xyz) - GEM_PLANES[i].w;
- if (e > e1)
- {
- e1 = e;
- n1 = GEM_PLANES[i].xyz;
- }
- }
- if (e1 < best)
- {
- best = e1;
- n = n1;
- }
- }
- return n;
-}
-
-constant float3 GEM_HUES[8] = {
- float3(0.08, 0.26, 0.96), float3(0.70, 0.30, 1.0), float3(0.58, 0.40, 1.0), float3(0.62, 0.97, 1.0),
- float3(0.0, 0.92, 1.0), float3(0.02, 0.58, 1.0), float3(0.05, 0.14, 0.70), float3(0.06, 0.20, 0.86)
-};
-
-static float3 s_gem_colour(float3 n)
-{
- float a = atan2(n.y, n.x) / 0.7853982 + 8.0;
- int i = int(floor(a)) % 8;
- float3 hue = mix(GEM_HUES[i], GEM_HUES[(i + 1) % 8], a - floor(a));
- float3 c = mix(float3(0.06, 0.45, 1.0), hue, smoothstep(0.03, 0.25, length(n.xy)));
- return pow(c, float3(2.2));
-}
-
static float2 sculpt_proto(float3 p, int theme, int shape)
{
if (theme == 3)
{
return s_voxels(p, shape);
}
- if (theme == 1)
- {
- return s_gem_model(p, shape);
- }
return s_rimmed(p, theme, shape);
}
@@ -1222,9 +1001,9 @@ static float2 sculpt_eval(float3 q, bool occ, constant Layer &layer)
int theme = id / 2, shape = id % 2;
float3 p = sculpt_point(q, layer);
float2 r;
- if (occ && (theme == 1 || theme == 3))
+ if (occ && theme == 3)
{
- float d2 = theme == 1 ? s_gem_sil(p.xy, shape) - GEM_RIM.x : s_pixel_outline(p.xy, shape);
+ 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);
}
@@ -1355,11 +1134,6 @@ static SculptMat sculpt_material(float mat, float3 p, int theme, int shape)
if (mat < 2.5) return s_mat(s_lin(0.95, 0.92, 0.85), 0.3, 0.6, 0.35, 0.25);
return s_mat(s_lin(0.1, 0.1, 0.11), 0.55, 0.05, 0.0, 0.1);
}
- if (theme == 1)
- {
- if (mat < 6.5) return s_mat(s_lin(0.06, 0.07, 0.30), 0.7, 0.12, 0.05, 0.06);
- return s_mat(s_gem_colour(s_gem_facet(p, shape)), 0.3, 0.55, 0.25, 0.2);
- }
if (theme == 2)
{
if ((primary && shape == 0) || (mat > 2.5 && mat < 3.5 && shape == 1)) return s_mat(s_lin(1.0, 0.40, 0.30), 0.35, 0.55, 0.35, 0.25);
diff --git a/crates/compositor/src/vk_shaders/layer.wgsl b/crates/compositor/src/vk_shaders/layer.wgsl
index 0afa58748..f1c122e6c 100644
--- a/crates/compositor/src/vk_shaders/layer.wgsl
+++ b/crates/compositor/src/vk_shaders/layer.wgsl
@@ -953,216 +953,10 @@ fn s_pixel_outline(p: vec2<f32>, shape: i32) -> f32 {
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>, 194>(
- vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500), vec4<f32>(-1.0000, 0.0000, 0.0000, 0.0000),
- vec4<f32>(0.6701, 0.7423, 0.0000, -0.0445), vec4<f32>(0.3396, -0.9406, 0.0000, 0.8267),
- vec4<f32>(-0.7433, 0.0000, 0.6690, 0.1003), vec4<f32>(0.4981, 0.5517, 0.6690, 0.0672),
- vec4<f32>(-0.5384, 0.0572, 0.8407, 0.1227), vec4<f32>(0.3250, 0.4398, 0.8373, 0.0992),
- vec4<f32>(0.2525, -0.6991, 0.6690, 0.7149), vec4<f32>(-0.5707, -0.0558, 0.8192, 0.1719),
- vec4<f32>(0.1274, -0.5495, 0.8257, 0.6069), vec4<f32>(0.2498, -0.4933, 0.8332, 0.6051),
- vec4<f32>(0.4180, 0.3846, 0.8230, 0.1463), vec4<f32>(-0.4678, 0.0600, 0.8818, 0.1348),
- vec4<f32>(0.2763, 0.3898, 0.8785, 0.1145), vec4<f32>(-0.4428, -0.0609, 0.8945, 0.1991),
- vec4<f32>(0.0034, -0.2407, 0.9706, 0.3843), vec4<f32>(0.1463, -0.1729, 0.9740, 0.3795),
- vec4<f32>(0.3348, 0.2853, 0.8981, 0.1791), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),
- vec4<f32>(-0.9247, -0.3807, 0.0000, 0.0845), vec4<f32>(-0.2425, 0.9701, 0.0000, -0.7065),
- vec4<f32>(0.3162, -0.9487, 0.0000, 1.0360), vec4<f32>(0.9162, 0.4008, 0.0000, 0.1197),
- vec4<f32>(-0.6992, -0.2879, 0.6544, 0.1621), vec4<f32>(-0.1834, 0.7336, 0.6544, -0.4361),
- vec4<f32>(-0.5935, -0.1579, 0.7892, 0.1137), vec4<f32>(-0.2785, 0.5032, 0.8181, -0.2726),
- vec4<f32>(0.2391, -0.7174, 0.6544, 0.8815), vec4<f32>(-0.5432, -0.3092, 0.7806, 0.2512),
- vec4<f32>(0.0499, -0.5957, 0.8016, 0.7239), vec4<f32>(0.6928, 0.3031, 0.6544, 0.1887),
- vec4<f32>(0.3144, -0.4913, 0.8123, 0.7383), vec4<f32>(0.5918, 0.1680, 0.7884, 0.2788),
- vec4<f32>(0.5372, 0.3248, 0.7784, 0.1307), vec4<f32>(-0.0022, 0.6040, 0.7970, -0.2600),
- vec4<f32>(-0.5197, -0.1213, 0.8457, 0.1169), vec4<f32>(-0.2438, 0.2827, 0.9277, -0.0861),
- vec4<f32>(-0.4593, -0.2814, 0.8425, 0.2657), vec4<f32>(-0.0463, -0.3759, 0.9255, 0.5100),
- vec4<f32>(0.2578, -0.2548, 0.9320, 0.5244), vec4<f32>(0.5289, 0.1347, 0.8379, 0.2882),
- vec4<f32>(0.4810, 0.3053, 0.8219, 0.1309), vec4<f32>(0.0665, 0.4124, 0.9086, -0.0825),
- vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500), vec4<f32>(0.0000, -1.0000, 0.0000, 0.7224),
- vec4<f32>(-1.0000, 0.0000, 0.0000, 0.1288), vec4<f32>(1.0000, 0.0000, 0.0000, 0.1288),
- vec4<f32>(0.7682, 0.6402, 0.0000, 0.0075), vec4<f32>(0.0000, 1.0000, 0.0000, -0.0600),
- vec4<f32>(-0.7682, 0.6402, 0.0000, 0.0075), vec4<f32>(0.0000, -0.8755, 0.4833, 0.7049),
- vec4<f32>(-0.8755, 0.0000, 0.4833, 0.1853), vec4<f32>(0.8755, 0.0000, 0.4833, 0.1853),
- vec4<f32>(0.6934, 0.5778, 0.4306, 0.0714), vec4<f32>(0.7205, 0.4859, 0.4948, 0.0976),
- vec4<f32>(0.0000, 0.9239, 0.3825, 0.0019), vec4<f32>(-0.6934, 0.5778, 0.4306, 0.0714),
- vec4<f32>(-0.7205, 0.4859, 0.4948, 0.0976), vec4<f32>(0.0000, -0.4966, 0.8680, 0.5186),
- vec4<f32>(-0.7029, 0.0000, 0.7113, 0.2134), vec4<f32>(0.7029, 0.0000, 0.7113, 0.2134),
- vec4<f32>(0.6092, 0.0477, 0.7916, 0.2127), vec4<f32>(-0.6092, 0.0477, 0.7916, 0.2127),
- vec4<f32>(0.0000, 0.1186, 0.9929, 0.2362), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),
- vec4<f32>(0.0000, -1.0000, 0.0000, 0.6856), vec4<f32>(-1.0000, 0.0000, 0.0000, -0.1104),
- vec4<f32>(1.0000, 0.0000, 0.0000, 0.2668), vec4<f32>(0.7809, 0.6247, 0.0000, -0.0246),
- vec4<f32>(0.0000, 1.0000, 0.0000, -0.3268), vec4<f32>(-0.7071, 0.7071, 0.0000, -0.3352),
- vec4<f32>(0.0000, -0.8357, 0.5492, 0.6553), vec4<f32>(-0.8478, 0.0000, 0.5304, -0.0140),
- vec4<f32>(-0.7734, -0.1600, 0.6134, 0.1163), vec4<f32>(0.8478, 0.0000, 0.5304, 0.3057),
- vec4<f32>(0.7734, -0.1600, 0.6134, 0.4081), vec4<f32>(0.6526, 0.5221, 0.5492, 0.0619),
- vec4<f32>(0.8337, 0.0180, 0.5520, 0.2985), vec4<f32>(0.0000, 0.8451, 0.5345, -0.1960),
- vec4<f32>(0.0998, 0.8168, 0.5683, -0.1587), vec4<f32>(-0.5909, 0.5909, 0.5492, -0.1977),
- vec4<f32>(-0.0826, 0.8224, 0.5629, -0.1965), vec4<f32>(-0.8334, 0.0176, 0.5524, -0.0155),
- vec4<f32>(0.0000, -0.7549, 0.6559, 0.6215), vec4<f32>(0.5776, 0.4621, 0.6729, 0.0893),
- vec4<f32>(0.6294, 0.1651, 0.7593, 0.2311), vec4<f32>(-0.5166, 0.5166, 0.6828, -0.1354),
- vec4<f32>(-0.6151, 0.1675, 0.7704, -0.0020), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),
- vec4<f32>(0.0000, -1.0000, 0.0000, 0.6856), vec4<f32>(-1.0000, 0.0000, 0.0000, -0.2484),
- vec4<f32>(1.0000, 0.0000, 0.0000, 0.4048), vec4<f32>(0.7809, 0.6247, 0.0000, 0.0516),
- vec4<f32>(0.0000, 1.0000, 0.0000, -0.3774), vec4<f32>(-0.7071, 0.7071, 0.0000, -0.4685),
- vec4<f32>(0.0000, -0.8357, 0.5492, 0.6553), vec4<f32>(-0.8378, 0.0000, 0.5460, -0.1262),
- vec4<f32>(-0.7868, -0.1311, 0.6032, -0.0151), vec4<f32>(0.8378, 0.0000, 0.5460, 0.4210),
- vec4<f32>(0.7868, -0.1311, 0.6032, 0.4989), vec4<f32>(0.6526, 0.5221, 0.5492, 0.1255),
- vec4<f32>(0.8353, 0.0036, 0.5498, 0.4191), vec4<f32>(0.0000, 0.8451, 0.5345, -0.2388),
- vec4<f32>(0.0998, 0.8168, 0.5683, -0.1863), vec4<f32>(-0.5909, 0.5909, 0.5492, -0.3092),
- vec4<f32>(-0.0826, 0.8224, 0.5629, -0.2495), vec4<f32>(-0.8353, 0.0035, 0.5498, -0.1265),
- vec4<f32>(0.0000, -0.8179, 0.5754, 0.6484), vec4<f32>(0.5776, 0.4621, 0.6729, 0.1456),
- vec4<f32>(0.6288, 0.1734, 0.7580, 0.3055), vec4<f32>(-0.5166, 0.5166, 0.6828, -0.2328),
- vec4<f32>(-0.6138, 0.1761, 0.7696, -0.0988), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),
- vec4<f32>(0.0000, -1.0000, 0.0000, 0.7040), vec4<f32>(-1.0000, 0.0000, 0.0000, -0.3864),
- vec4<f32>(1.0000, 0.0000, 0.0000, 0.5382), vec4<f32>(0.7809, 0.6247, 0.0000, 0.1242),
- vec4<f32>(0.0000, 1.0000, 0.0000, -0.4280), vec4<f32>(-0.7071, 0.7071, 0.0000, -0.6019),
- vec4<f32>(0.0000, -0.8357, 0.5492, 0.6707), vec4<f32>(-0.8423, 0.0000, 0.5391, -0.2446),
- vec4<f32>(-0.7508, -0.2048, 0.6280, -0.0518), vec4<f32>(0.8357, 0.0000, 0.5492, 0.5322),
- vec4<f32>(0.6526, 0.5221, 0.5492, 0.1861), vec4<f32>(0.0000, 0.8451, 0.5345, -0.2815),
- vec4<f32>(0.0998, 0.8168, 0.5683, -0.2143), vec4<f32>(-0.5909, 0.5909, 0.5492, -0.4206),
- vec4<f32>(-0.1072, 0.8172, 0.5662, -0.3102), vec4<f32>(-0.8340, 0.0131, 0.5516, -0.2456),
- vec4<f32>(0.0000, -0.8010, 0.5987, 0.6562), vec4<f32>(0.8231, 0.0000, 0.5679, 0.5291),
- vec4<f32>(0.5776, 0.4621, 0.6729, 0.1993), vec4<f32>(0.6279, 0.1855, 0.7559, 0.3739),
- vec4<f32>(-0.5355, 0.5355, 0.6530, -0.3524), vec4<f32>(-0.6448, 0.1822, 0.7423, -0.2131),
- vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500), vec4<f32>(-0.6163, -0.7875, 0.0000, 0.7006),
- vec4<f32>(-0.9985, -0.0555, 0.0000, 0.3657), vec4<f32>(0.9950, -0.0995, 0.0000, -0.0398),
- vec4<f32>(0.7926, 0.6097, 0.0000, -0.3900), vec4<f32>(0.0000, 1.0000, 0.0000, -0.4004),
- vec4<f32>(-0.7593, 0.6508, 0.0000, -0.0440), vec4<f32>(-0.5073, -0.6482, 0.5679, 0.6618),
- vec4<f32>(-0.8611, -0.0478, 0.5061, 0.3913), vec4<f32>(-0.7393, -0.3013, 0.6022, 0.5251),
- vec4<f32>(0.8405, -0.0840, 0.5353, 0.0467), vec4<f32>(0.5328, -0.3560, 0.7677, 0.3348),
- vec4<f32>(0.6524, 0.5018, 0.5679, -0.2358), vec4<f32>(0.8129, 0.0099, 0.5823, 0.0074),
- vec4<f32>(0.0000, 0.8231, 0.5679, -0.2444), vec4<f32>(-0.6249, 0.5357, 0.5679, 0.0489),
- vec4<f32>(-0.8088, 0.0631, 0.5847, 0.3337), vec4<f32>(-0.4667, -0.5964, 0.6531, 0.6337),
- vec4<f32>(-0.4922, -0.5381, 0.6842, 0.6115), vec4<f32>(0.6153, 0.4733, 0.6303, -0.2044),
- vec4<f32>(0.6249, 0.3006, 0.7206, -0.0972), vec4<f32>(0.0000, 0.7790, 0.6271, -0.2143),
- vec4<f32>(-0.5567, 0.4772, 0.6799, 0.0767), vec4<f32>(-0.6567, 0.2139, 0.7232, 0.2410),
- vec4<f32>(-0.3316, -0.0488, 0.9422, 0.3547), vec4<f32>(0.0000, 0.0000, -1.0000, -0.0500),
- vec4<f32>(-0.8384, -0.5450, 0.0000, 0.5958), vec4<f32>(-0.4138, 0.9104, 0.0000, -0.4277),
- vec4<f32>(0.0000, -1.0000, 0.0000, 0.9800), vec4<f32>(0.7853, -0.6192, 0.0000, 0.8813),
- vec4<f32>(1.0000, 0.0000, 0.0000, 0.5382), vec4<f32>(0.0566, 0.9984, 0.0000, -0.5254),
- vec4<f32>(-0.7112, -0.4623, 0.5297, 0.5848), vec4<f32>(-0.3032, 0.6670, 0.6806, -0.2113),
- vec4<f32>(-0.4105, 0.3857, 0.8263, 0.0163), vec4<f32>(-0.4507, 0.2882, 0.8449, 0.0914),
- vec4<f32>(0.0000, -0.6993, 0.7148, 0.7925), vec4<f32>(-0.0624, -0.6620, 0.7469, 0.7654),
- vec4<f32>(-0.4608, -0.4581, 0.7601, 0.5969), vec4<f32>(0.6592, -0.5198, 0.5434, 0.8214),
- vec4<f32>(0.0113, -0.6787, 0.7344, 0.7792), vec4<f32>(0.3396, -0.5477, 0.7646, 0.7702),
- vec4<f32>(0.7207, 0.0000, 0.6932, 0.4919), vec4<f32>(0.6182, -0.2793, 0.7347, 0.6498),
- vec4<f32>(0.0449, 0.7917, 0.6092, -0.3253), vec4<f32>(0.1069, 0.6384, 0.7622, -0.1836),
- vec4<f32>(0.4599, 0.3272, 0.8255, 0.1892), vec4<f32>(-0.4252, 0.3195, 0.8468, 0.0653),
- vec4<f32>(-0.3146, -0.4157, 0.8534, 0.5652), vec4<f32>(0.0252, -0.6408, 0.7673, 0.7539),
- vec4<f32>(0.1792, -0.5010, 0.8467, 0.6871), vec4<f32>(0.1111, 0.6228, 0.7744, -0.1701),
- vec4<f32>(0.1536, 0.5517, 0.8198, -0.0987), vec4<f32>(0.0165, -0.1450, 0.9893, 0.3889),
- vec4<f32>(-0.0842, -0.2545, 0.9634, 0.4549), vec4<f32>(-0.1798, -0.2748, 0.9446, 0.4657),
- vec4<f32>(0.1433, -0.1696, 0.9750, 0.4318), vec4<f32>(0.1693, -0.2060, 0.9638, 0.4650)
-);
-const GEM_PIECE = array<i32, 9>(0, 19, 44, 65, 89, 113, 136, 161, 194);
-const GEM_BOX = array<vec3<f32>, 4>(
- vec3<f32>(0.324, -0.524, 0.165),
- vec3<f32>(0.334, 0.474, 0.125),
- vec3<f32>(0.099, -0.520, 0.175),
- vec3<f32>(0.449, 0.470, 0.135)
-);
-const GEM_OUTLINE = array<vec2<f32>, 43>(
- vec2<f32>(0.0000, -0.0600), vec2<f32>(0.0000, -0.8790), vec2<f32>(0.6480, -0.6450), vec2<f32>(0.1890, -0.6810),
- vec2<f32>(0.3150, -0.9870), vec2<f32>(0.5310, -0.9150), vec2<f32>(0.4050, -0.6270), vec2<f32>(-0.1288, -0.7224),
- vec2<f32>(0.1288, -0.7224), vec2<f32>(0.1288, -0.1428), vec2<f32>(0.0598, -0.0600), vec2<f32>(-0.0598, -0.0600),
- vec2<f32>(-0.1288, -0.1428), vec2<f32>(0.1104, -0.6856), vec2<f32>(0.2668, -0.6856), vec2<f32>(0.2668, -0.3728),
- vec2<f32>(0.2300, -0.3268), vec2<f32>(0.1472, -0.3268), vec2<f32>(0.1104, -0.3636), vec2<f32>(0.2484, -0.6856),
- vec2<f32>(0.4048, -0.6856), vec2<f32>(0.4048, -0.4234), vec2<f32>(0.3680, -0.3774), vec2<f32>(0.2852, -0.3774),
- vec2<f32>(0.2484, -0.4142), vec2<f32>(0.3864, -0.7040), vec2<f32>(0.5382, -0.7040), vec2<f32>(0.5382, -0.4740),
- vec2<f32>(0.5014, -0.4280), vec2<f32>(0.4232, -0.4280), vec2<f32>(0.3864, -0.4648), vec2<f32>(-0.3312, -0.6304),
- vec2<f32>(-0.1196, -0.7960), vec2<f32>(-0.0920, -0.5200), vec2<f32>(-0.1840, -0.4004), vec2<f32>(-0.2852, -0.4004),
- vec2<f32>(-0.3404, -0.4648), vec2<f32>(-0.3128, -0.6120), vec2<f32>(-0.0736, -0.9800), vec2<f32>(0.3496, -0.9800),
- vec2<f32>(0.5382, -0.7408), vec2<f32>(0.5382, -0.5568), vec2<f32>(-0.1104, -0.5200)
-);
-const GEM_OUTLINE_N = array<i32, 9>(0, 3, 7, 13, 19, 25, 31, 37, 43);
-const GEM_RIM = vec2<f32>(0.060, 0.150);
-// </prism-glow-gem>
-
-fn s_gem_cut(p: vec3<f32>, shape: i32) -> f32 {
- let far = length(max(abs(p - GEM_BOX[2 * shape]) - GEM_BOX[2 * shape + 1], vec3<f32>(0.0)));
- if far > 0.05 {
- return far;
- }
- var d = 1e9;
- for (var k = select(2, 0, shape == 0); k < select(8, 2, shape == 0); k++) {
- var e = -1e9;
- for (var i = GEM_PIECE[k]; i < GEM_PIECE[k + 1]; i++) {
- e = max(e, dot(p, GEM_PLANES[i].xyz) - GEM_PLANES[i].w);
- }
- d = min(d, e);
- }
- return d;
-}
-
-fn s_gem_sil(p: vec2<f32>, shape: i32) -> f32 {
- var d = 1e9;
- for (var k = select(2, 0, shape == 0); k < select(8, 2, shape == 0); k++) {
- let a0 = GEM_OUTLINE_N[k];
- let n = GEM_OUTLINE_N[k + 1] - a0;
- var inside = -1e9;
- var outside = 1e9;
- for (var i = 0; i < n; i++) {
- let a = GEM_OUTLINE[a0 + i];
- let e = GEM_OUTLINE[a0 + (i + 1) % n] - a;
- let w = p - a;
- inside = max(inside, (w.x * e.y - w.y * e.x) / length(e));
- outside = min(outside, length(w - e * saturate(dot(w, e) / dot(e, e))));
- }
- d = min(d, select(outside, inside, inside <= 0.0));
- }
- return d;
-}
-
-fn s_gem_model(p: vec3<f32>, shape: i32) -> vec2<f32> {
- let sil = s_gem_sil(p.xy, shape);
- let w = GEM_RIM.x;
- let zt = GEM_RIM.y;
- let tray = s_extrude(sil - w, p.z - 0.5 * (SCULPT_HOVER + zt), 0.5 * (zt - SCULPT_HOVER), 0.012);
- let bead = length(vec2<f32>(sil - 0.5 * w, p.z - zt)) - 0.5 * w;
- return s_opu(vec2<f32>(min(tray, bead), 5.0), vec2<f32>(s_gem_cut(p, shape), 8.0));
-}
-
-fn s_gem_facet(p: vec3<f32>, shape: i32) -> vec3<f32> {
- var best = 1e9;
- var n = vec3<f32>(0.0, 0.0, 1.0);
- for (var k = select(2, 0, shape == 0); k < select(8, 2, shape == 0); k++) {
- var e1 = -1e9;
- var n1 = vec3<f32>(0.0, 0.0, 1.0);
- for (var i = GEM_PIECE[k]; i < GEM_PIECE[k + 1]; i++) {
- let e = dot(p, GEM_PLANES[i].xyz) - GEM_PLANES[i].w;
- if e > e1 {
- e1 = e;
- n1 = GEM_PLANES[i].xyz;
- }
- }
- if e1 < best {
- best = e1;
- n = n1;
- }
- }
- return n;
-}
-
-const GEM_HUES = array<vec3<f32>, 8>(
- vec3<f32>(0.08, 0.26, 0.96), vec3<f32>(0.70, 0.30, 1.0), vec3<f32>(0.58, 0.40, 1.0), vec3<f32>(0.62, 0.97, 1.0),
- vec3<f32>(0.0, 0.92, 1.0), vec3<f32>(0.02, 0.58, 1.0), vec3<f32>(0.05, 0.14, 0.70), vec3<f32>(0.06, 0.20, 0.86)
-);
-
-fn s_gem_colour(n: vec3<f32>) -> vec3<f32> {
- let a = atan2(n.y, n.x) / 0.7853982 + 8.0;
- let i = i32(floor(a)) % 8;
- let hue = mix(GEM_HUES[i], GEM_HUES[(i + 1) % 8], a - floor(a));
- let c = mix(vec3<f32>(0.06, 0.45, 1.0), hue, smoothstep(0.03, 0.25, length(n.xy)));
- return pow(c, vec3<f32>(2.2));
-}
-
fn sculpt_proto(p: vec3<f32>, theme: i32, shape: i32) -> vec2<f32> {
if theme == 3 {
return s_voxels(p, shape);
}
- if theme == 1 {
- return s_gem_model(p, shape);
- }
return s_rimmed(p, theme, shape);
}
@@ -1181,13 +975,8 @@ fn sculpt_eval(q: vec3<f32>, occ: bool) -> vec2<f32> {
let shape = id % 2;
let p = sculpt_point(q);
var r: vec2<f32>;
- if occ && (theme == 1 || theme == 3) {
- var d2: f32;
- if theme == 1 {
- d2 = s_gem_sil(p.xy, shape) - GEM_RIM.x;
- } else {
- d2 = s_pixel_outline(p.xy, shape);
- }
+ if occ && theme == 3 {
+ 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 {
@@ -1290,12 +1079,6 @@ fn sculpt_material(mat: f32, p: vec3<f32>, theme: i32, shape: i32) -> SculptMat
}
return SculptMat(s_lin(0.1, 0.1, 0.11), 0.55, 0.05, 0.0, 0.1);
}
- if theme == 1 {
- if mat < 6.5 {
- return SculptMat(s_lin(0.06, 0.07, 0.30), 0.7, 0.12, 0.05, 0.06);
- }
- return SculptMat(s_gem_colour(s_gem_facet(p, shape)), 0.3, 0.55, 0.25, 0.2);
- }
if theme == 2 {
if (primary && shape == 0) || (mat > 2.5 && mat < 3.5 && shape == 1) {
return SculptMat(s_lin(1.0, 0.40, 0.30), 0.35, 0.55, 0.35, 0.25);
diff --git a/crates/compositor/tests/cursor_model_render.rs b/crates/compositor/tests/cursor_model_render.rs
index 86d28bf70..fbcc25dc9 100644
--- a/crates/compositor/tests/cursor_model_render.rs
+++ b/crates/compositor/tests/cursor_model_render.rs
@@ -161,11 +161,11 @@ fn cursors_dir() -> String {
.replace('\\', "/")
}
-/// Les cinq thèmes d'origine et les hotspots de leur flèche et de leur main plates
-/// (`CURSOR_THEMES`, `src/lib/cursor/cursorThemes.ts`, sur 32).
-const SCULPTED: [(&str, [f32; 2], [f32; 2]); 5] = [
+/// Les thèmes d'origine qui ont un modèle (Prism Glow n'en a pas : son dessin est extrudé) et les
+/// hotspots de leur flèche et de leur main plates (`CURSOR_THEMES`,
+/// `src/lib/cursor/cursorThemes.ts`, sur 32).
+const SCULPTED: [(&str, [f32; 2], [f32; 2]); 4] = [
("studio-ink", [6.2304, 2.0992], [12.848, 2.0704]),
- ("prism-glow", [6.3456, 2.0672], [11.968, 2.0352]),
("pop-coral", [10.4768, 2.1792], [12.3456, 2.0]),
("pixel-candy", [7.3664, 2.0], [13.376, 1.9264]),
("star-sprout", [4.7232, 2.1152], [13.1712, 2.0384]),
@@ -765,10 +765,10 @@ fn the_motion_blur_trail_draws_modelled_copies() {
assert!(rgba != flat, "la traînée 3D est celle du sprite plat");
}
-/// Les dix curseurs sculptés (cinq thèmes, flèche et main), dessinés par le shader et non
-/// extrudés d'un PNG : chacun est là, sa pointe sur le hotspot, son corps en bas à droite de
-/// celle-ci (y vers le bas : un modèle retourné finirait au-dessus), et il porte son ombre en
-/// l'air.
+/// Les curseurs sculptés (flèche et main de chaque thème qui a un modèle), dessinés par le
+/// shader et non extrudés d'un PNG : chacun est là, sa pointe sur le hotspot, son corps en bas à
+/// droite de celle-ci (y vers le bas : un modèle retourné finirait au-dessus), et il porte son
+/// ombre en l'air.
#[test]
fn the_sculpted_cursors_stand_at_the_hotspot() {
let Some(gpu) = gpu() else { return };
@@ -865,7 +865,7 @@ fn contact_sheets() {
}
tilted.save(format!("{dir}/states-touch-flat-and-iso.png")).expect("planche");
- // Les dix curseurs sculptés : un thème par ligne, flèche et main en l'air sur l'écran à plat,
+ // Les curseurs sculptés : un thème par ligne, flèche et main en l'air sur l'écran à plat,
// puis posées sur l'écran incliné.
let cases = [("arrow", "null", false), ("pointer", "null", false), ("arrow", r#""iso""#, true), ("pointer", r#""iso""#, true)];
let mut sculpted = image::RgbaImage::new(4 * CELL, SCULPTED.len() as u32 * CELL);
diff --git a/design/cursors/3d-direction.md b/design/cursors/3d-direction.md
index db5661d53..655fd07c6 100644
--- a/design/cursors/3d-direction.md
+++ b/design/cursors/3d-direction.md
@@ -13,15 +13,15 @@ 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 | The 2D art given volume: a navy outline (tray and bead) around a cut gem with a wide girdle and a crown fanning out from one point; each facet a flat colour of the drawing (cyan, pale cyan, violet, blue). | The same: an index column, three fingers side by side, the thumb and a faceted palm in one navy outline. |
+| Prism Glow | No sculpted model: its faceted drawing is extruded as drawn, with a beveled edge, like the default cursors. | The same. |
| 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, a coral layer behind it offset down-left, two coral click dashes. |
| 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, Star Sprout and Prism Glow keep their drawn outline, as in
+Studio Ink, Pop Coral and Star Sprout keep their drawn outline, as in
`3d-concept.png` (and `star-sprout/3d-reference.png` for the Star Sprout hand).
Each piece is a tray in the outline colour under its silhouette, a rounded bead
-along the stroke and a puffy colour cushion inside it (a cut gem for Prism Glow); the grooves between the
+along the stroke and a puffy colour cushion inside it; the grooves between the
fingers become ridges of the outline colour. The three arrows share one polygon
and the three gloves one construction, each glove measured on its own drawing
(`RIM_POLY`, `RIM_GLOVE`). What stands in front is theme-specific: Studio Ink's
@@ -36,9 +36,7 @@ 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. 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 tables
-agree.
+shapes, and a test checks that the shaders mirror its constants. Pixel Candy's
+voxel grids are tables written by `scripts/generate-pixel-candy-voxels.mjs`:
+change a grid there and run the script; it rewrites all three shaders, and a
+test checks the tables agree.
diff --git a/design/cursors/requirements.md b/design/cursors/requirements.md
index 2245455c6..179002922 100644
--- a/design/cursors/requirements.md
+++ b/design/cursors/requirements.md
@@ -41,7 +41,7 @@ their 3D models.
| Theme | Arrow | Hand |
| --- | --- | --- |
| 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 | Faceted gem in the navy outline of the 2D art; flat facet colours from the drawing. | Faceted palm and fingers in the same navy outline. |
+| Prism Glow | The faceted drawing extruded as drawn, beveled edge; no sculpted model. | The same. |
| 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 offset becomes a layer behind it; the coral click dashes become physical pieces. |
| 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`. |
diff --git a/docs/3d-effects-v2.md b/docs/3d-effects-v2.md
index 98aa45669..ee74e5716 100644
--- a/docs/3d-effects-v2.md
+++ b/docs/3d-effects-v2.md
@@ -287,19 +287,14 @@ du bord (0,48 au pire), sous 1 texel au-delà (le flou arrondit les crêtes).
### B.3 bis Les curseurs sculptés
-La flèche et la main des cinq thèmes d'origine sont **modélisées à la main**, en fonctions de
+La flèche et la main des thèmes d'origine sont **modélisées à la main**, en fonctions de
distance signée écrites dans les trois shaders (`sculpt_proto`, `sculpt_material`) : voxels
biseautés pour Pixel Candy ; pour Studio Ink, Pop Coral et Star Sprout des pièces qui gardent le
trait de leur dessin : un plateau et un jonc de la couleur du trait, un coussin de couleur dedans
-(`s_rimmed`) ; pour Prism Glow le même trait marine autour d'une pierre taillée (`s_gem_model`). Le PNG du thème reste l'art en
-2D. En 3D, la scène nomme le modèle ; `sculpt.rs` en tient la boîte, qui pose le hotspot (pointe
+(`s_rimmed`). Prism Glow n'a pas de modèle : son dessin à facettes est extrudé comme tout sprite
+(B.3). Le PNG du thème reste l'art en 2D. En 3D, la scène nomme le modèle ; `sculpt.rs` en tient la boîte, qui pose le hotspot (pointe
de la flèche, bout de l'index), règle la garde au sol et borne la boîte de dessin. Emplacement du
cbuffer : `trail_a` = [modèle, épaisseur sous z = 0, hauteur au-dessus, 0] (`cursor_model_cb`).
-Les pièces de Prism Glow (tête et queue de la flèche ; index, trois doigts, pouce et paume de la
-main) sont des polyèdres convexes, le max des plans de leurs faces : une table que
-`scripts/generate-prism-glow-gem.mjs` calcule (enveloppe convexe de points posés à la main) et
-écrit dans les trois shaders, avec leur contour, que suit le trait. Chaque facette est un aplat
-aux teintes du dessin 2D, choisi selon où elle regarde (`s_gem_colour`), sous la lampe commune.
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
@@ -309,9 +304,9 @@ face.
et un reflet même sur une face plane ; une lumière d'appoint faible ; le côté ombré teinté par
la matière ; occlusion ambiante, ombre propre douce vers la lampe, studio dans les reflets,
liseré de Fresnel ; tone map Khronos PBR Neutral.
-- **Ombre sur l'écran** : celle de B.3. Les pierres et les voxels donnent de mauvaises distances
- loin de leur surface (bornes de plans, champ de grille) : leur ombre vient de leur contour
- extrudé, le bord du trait marine pour Prism Glow, la face et l'anneau violet pour Pixel Candy.
+- **Ombre sur l'écran** : celle de B.3. Les voxels donnent de mauvaises distances loin de leur
+ surface (champ de grille) : l'ombre de Pixel Candy vient de son contour extrudé, la face et
+ l'anneau violet.
- **Antialiasing** : la silhouette l'est par la marche (la distance minimale frôlée, en pixels,
donne la couverture). Les bords intérieurs (deux matières, une arête, un arrondi serré, un
joint de voxels) sont suréchantillonnés : quatre sondes à un demi-pixel du point touché, dans
diff --git a/scripts/generate-prism-glow-gem.mjs b/scripts/generate-prism-glow-gem.mjs
deleted file mode 100644
index 9f14f3c08..000000000
--- a/scripts/generate-prism-glow-gem.mjs
+++ /dev/null
@@ -1,355 +0,0 @@
-// Cut-gem geometry of the Prism Glow 3D cursors (mode 15, theme 1).
-// Run with `node scripts/generate-prism-glow-gem.mjs` after changing a piece below: it rewrites
-// the GEM_PLANES, GEM_PIECE and GEM_BOX tables of the three compositor shaders, between their
-// `<prism-glow-gem>` markers.
-//
-// Every piece is a convex polyhedron, stored as the planes of its faces (unit outward normal,
-// offset): the shader takes the max of a piece's planes and the min over the pieces. Around them
-// runs the navy outline of the 2D art (GEM_OUTLINE, the pieces' outlines, and GEM_RIM). Coordinates
-// are the prototype frame of crates/compositor/src/sculpt.rs: cursor height 1, x right, y UP,
-// z toward the camera, hotspot at the origin, screen at z = 0, underside of every model at
-// SCULPT_HOVER.
-
-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");
-const HOVER = 0.05;
-
-// 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 navy outline, as on the other outlined themes: a stroke `RIM_W` wide around the pieces, a
-// tray under it and a rounded bead on it at `RIM_Z`. The pieces are drawn at full size below, then
-// shrunk and moved (`place`) so that the outer edge of the stroke is where their tip was: on the
-// hotspot, like the other outlined themes.
-const RIM_W = 0.06;
-const RIM_Z = 0.15;
-
-// The arrow: a head with a wide girdle and a crown that fans out from one point, and the tail.
-const ARROW = [
- {
- name: "head",
- outline: [
- [-0.02, 0.03],
- [-0.02, -0.88],
- [0.7, -0.62],
- ],
- zg: 0.15,
- c: 0.07,
- zc: 0.2,
- lift: 0.02,
- tops: [[0.18, -0.42, 0.28]],
- },
- {
- name: "tail",
- outline: [
- [0.19, -0.66],
- [0.33, -1.0],
- [0.57, -0.92],
- [0.43, -0.6],
- ],
- zg: 0.15,
- c: 0.05,
- zc: 0.19,
- lift: 0.012,
- tops: [[0.38, -0.79, 0.245]],
- },
-];
-
-// 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",
- outline: [
- [-0.14, -0.72],
- [0.14, -0.72],
- [0.14, -0.09],
- [0.065, 0.0],
- [-0.065, 0.0],
- [-0.14, -0.09],
- ],
- zg: 0.15,
- c: 0.03,
- zc: 0.2,
- tops: [
- [-0.035, -0.045, 0.25],
- [0.035, -0.045, 0.25],
- [0.0, -0.5, 0.3],
- ],
- },
- {
- name: "middle",
- outline: [
- [0.12, -0.68],
- [0.29, -0.68],
- [0.29, -0.34],
- [0.25, -0.29],
- [0.16, -0.29],
- [0.12, -0.33],
- ],
- zg: 0.15,
- c: 0.025,
- zc: 0.185,
- tops: [
- [0.205, -0.345, 0.23],
- [0.205, -0.57, 0.275],
- ],
- },
- {
- name: "ring",
- outline: [
- [0.27, -0.68],
- [0.44, -0.68],
- [0.44, -0.395],
- [0.4, -0.345],
- [0.31, -0.345],
- [0.27, -0.385],
- ],
- zg: 0.15,
- c: 0.025,
- zc: 0.185,
- tops: [
- [0.355, -0.4, 0.23],
- [0.355, -0.59, 0.27],
- ],
- },
- {
- name: "pinky",
- outline: [
- [0.42, -0.7],
- [0.585, -0.7],
- [0.585, -0.45],
- [0.545, -0.4],
- [0.46, -0.4],
- [0.42, -0.44],
- ],
- zg: 0.15,
- c: 0.025,
- zc: 0.185,
- tops: [
- [0.5, -0.455, 0.23],
- [0.5, -0.61, 0.265],
- ],
- },
- {
- name: "thumb",
- outline: [
- [-0.36, -0.62],
- [-0.13, -0.8],
- [-0.1, -0.5],
- [-0.2, -0.37],
- [-0.31, -0.37],
- [-0.37, -0.44],
- ],
- zg: 0.15,
- c: 0.03,
- zc: 0.19,
- tops: [
- [-0.25, -0.47, 0.27],
- [-0.2, -0.6, 0.28],
- [-0.3, -0.55, 0.25],
- ],
- },
- {
- name: "palm",
- outline: [
- [-0.34, -0.6],
- [-0.08, -1.0],
- [0.38, -1.0],
- [0.585, -0.74],
- [0.585, -0.54],
- [-0.12, -0.5],
- ],
- zg: 0.15,
- c: 0.035,
- zc: 0.18,
- tops: [
- [-0.04, -0.63, 0.3],
- [0.26, -0.67, 0.29],
- [0.03, -0.9, 0.24],
- [0.47, -0.68, 0.26],
- [0.22, -0.86, 0.265],
- [-0.19, -0.7, 0.255],
- [0.43, -0.84, 0.235],
- ],
- },
-];
-
-const sub = (a, b) => a.map((v, i) => v - b[i]);
-const dot = (a, b) => a.reduce((s, v, i) => s + v * b[i], 0);
-const cross = (a, b) => [
- a[1] * b[2] - a[2] * b[1],
- a[2] * b[0] - a[0] * b[2],
- a[0] * b[1] - a[1] * b[0],
-];
-
-function plane(n, w) {
- const len = Math.hypot(...n);
- return [...n.map((v) => v / len), w / len];
-}
-
-function edgeFrame(a, b) {
- const len = Math.hypot(b[0] - a[0], b[1] - a[1]);
- const d = [(b[0] - a[0]) / len, (b[1] - a[1]) / len];
- return { len, d, inward: [-d[1], d[0]] };
-}
-
-// 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) => {
- const { d, inward } = edgeFrame(a, outline[(i + 1) % outline.length]);
- return { p: [a[0] + inward[0] * c, a[1] + inward[1] * c], d };
- });
- return lines.map(({ p: p2, d: d2 }, i) => {
- const { p: p1, d: d1 } = lines[(i + lines.length - 1) % lines.length];
- const det = d1[0] * -d2[1] + d2[0] * d1[1];
- const t = ((p2[0] - p1[0]) * -d2[1] + d2[0] * (p2[1] - p1[1])) / det;
- return [p1[0] + d1[0] * t, p1[1] + d1[1] * t];
- });
-}
-
-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]),
- ...ring.map(([x, y]) => [x, y, zc]),
- ...mids,
- ...tops,
- ];
-}
-
-// Faces of the convex hull: every plane through three of the points with all the others behind.
-function hullPlanes(points) {
- const planes = [];
- const eps = 1e-7;
- for (let i = 0; i < points.length; i++) {
- for (let j = i + 1; j < points.length; j++) {
- for (let k = j + 1; k < points.length; k++) {
- const n = cross(sub(points[j], points[i]), sub(points[k], points[i]));
- if (Math.hypot(...n) < 1e-9) continue;
- let p = plane(n, dot(n, points[i]));
- const side = points.map((q) => dot(p.slice(0, 3), q) - p[3]);
- if (side.some((s) => s > eps) && side.some((s) => s < -eps)) continue;
- if (side.some((s) => s > eps)) p = p.map((v) => -v);
- if (!planes.some((q) => q.every((v, m) => Math.abs(v - p[m]) < 1e-6))) planes.push(p);
- }
- }
- }
- return planes;
-}
-
-function box(points) {
- const lo = [0, 1, 2].map((i) => Math.min(...points.map((p) => p[i])));
- const hi = [0, 1, 2].map((i) => Math.max(...points.map((p) => p[i])));
- return [lo.map((v, i) => (v + hi[i]) / 2), lo.map((v, i) => (hi[i] - v) / 2 + 0.01)];
-}
-
-// Scaled by `k` about `from`, which lands on `to`; heights are kept.
-function place(model, from, to, k) {
- const at = ([x, y]) => [to[0] + k * (x - from[0]), to[1] + k * (y - from[1])];
- return model.map((piece) => ({
- ...piece,
- outline: piece.outline.map(at),
- c: piece.c * k,
- tops: piece.tops.map(([x, y, z]) => [...at([x, y]), z]),
- }));
-}
-
-// The arrow's tip vertex and the top middle of the index go one stroke below the hotspot.
-const arrow = place(ARROW, [-0.02, 0.03], [0, -RIM_W], 0.9);
-const hand = place(HAND, [0, 0], [0, -RIM_W], 0.92);
-const all = [...arrow, ...hand];
-const pieces = all.map((piece) => hullPlanes(gemPoints(piece)));
-const planes = pieces.flat();
-const starts = pieces.reduce((s, p) => [...s, s[s.length - 1] + p.length], [0]);
-const boxes = [...box(arrow.flatMap(gemPoints)), ...box(hand.flatMap(gemPoints))];
-const outline = all.flatMap((piece) => piece.outline);
-const outlineStarts = all.reduce((s, p) => [...s, s[s.length - 1] + p.outline.length], [0]);
-
-const num = (v, digits) => {
- const s = v.toFixed(digits);
- return Number(s) === 0 ? (0).toFixed(digits) : s;
-};
-
-function block(lang) {
- const v4 = { wgsl: "vec4<f32>", hlsl: "float4", metal: "float4" }[lang];
- const v3 = { wgsl: "vec3<f32>", hlsl: "float3", metal: "float3" }[lang];
- const rows = [];
- for (let i = 0; i < planes.length; i += 2) {
- const pair = planes.slice(i, i + 2).map((p) => `${v4}(${p.map((v) => num(v, 4)).join(", ")})`);
- rows.push(` ${pair.join(", ")}`);
- }
- const boxRows = boxes.map((b) => ` ${v3}(${b.map((v) => num(v, 3)).join(", ")})`);
- const v2 = { wgsl: "vec2<f32>", hlsl: "float2", metal: "float2" }[lang];
- const outlineRows = [];
- for (let i = 0; i < outline.length; i += 4) {
- const four = outline.slice(i, i + 4).map((p) => `${v2}(${p.map((v) => num(v, 4)).join(", ")})`);
- outlineRows.push(` ${four.join(", ")}`);
- }
- const rim = `${v2}(${num(RIM_W, 3)}, ${num(RIM_Z, 3)})`;
- if (lang === "wgsl") {
- return [
- `const GEM_PLANES = array<vec4<f32>, ${planes.length}>(`,
- rows.join(",\n"),
- ");",
- `const GEM_PIECE = array<i32, ${starts.length}>(${starts.join(", ")});`,
- "const GEM_BOX = array<vec3<f32>, 4>(",
- boxRows.join(",\n"),
- ");",
- `const GEM_OUTLINE = array<vec2<f32>, ${outline.length}>(`,
- outlineRows.join(",\n"),
- ");",
- `const GEM_OUTLINE_N = array<i32, ${outlineStarts.length}>(${outlineStarts.join(", ")});`,
- `const GEM_RIM = ${rim};`,
- ].join("\n");
- }
- const decl = lang === "hlsl" ? "static const" : "constant";
- return [
- `${decl} float4 GEM_PLANES[${planes.length}] = {`,
- rows.join(",\n"),
- "};",
- `${decl} int GEM_PIECE[${starts.length}] = { ${starts.join(", ")} };`,
- `${decl} float3 GEM_BOX[4] = {`,
- boxRows.join(",\n"),
- "};",
- `${decl} float2 GEM_OUTLINE[${outline.length}] = {`,
- outlineRows.join(",\n"),
- "};",
- `${decl} int GEM_OUTLINE_N[${outlineStarts.length}] = { ${outlineStarts.join(", ")} };`,
- `${decl} float2 GEM_RIM = ${rim};`,
- ].join("\n");
-}
-
-const targets = [
- ["vk_shaders/layer.wgsl", "wgsl"],
- ["shaders.hlsl", "hlsl"],
- ["shaders.metal", "metal"],
-];
-const marked = /(\/\/ <prism-glow-gem>\n)[\s\S]*?(\/\/ <\/prism-glow-gem>)/;
-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 <prism-glow-gem> 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(
- `${planes.length} planes: ${all.map((g, i) => `${g.name} ${pieces[i].length}`).join(", ")}`,
-);
diff --git a/src/lib/cursor/cursorThemes.test.ts b/src/lib/cursor/cursorThemes.test.ts
index e712e8ad4..863acb24f 100644
--- a/src/lib/cursor/cursorThemes.test.ts
+++ b/src/lib/cursor/cursorThemes.test.ts
@@ -67,7 +67,9 @@ describe("normalizeCursorThemeId", () => {
// The compositor models these two states itself (`crates/compositor/src/sculpt.rs`, which
// knows the same names): in 3D the scene names the model, and the sprite stays the flat art.
- it.each(CURSOR_THEMES)("names the sculpted 3D arrow and hand of $name", (theme) => {
+ // Prism Glow is the exception: its drawing is extruded, like the default art.
+ const sculptedThemes = CURSOR_THEMES.filter((theme) => theme.id !== "prism-glow");
+ it.each(sculptedThemes)("names the sculpted 3D arrow and hand of $name", (theme) => {
const flat = resolveCursorSprites(theme.id);
const sprites = resolveCursorSprites(theme.id, [], true);
for (const state of ["arrow", "pointer"] as const) {
@@ -78,8 +80,8 @@ describe("normalizeCursorThemeId", () => {
expect(sprites.text).toBe(DEFAULT_CURSOR_SPRITES.text);
});
- it("leaves the default art to the extruded sprite in 3D", () => {
- for (const sprite of Object.values(resolveCursorSprites(DEFAULT_CURSOR_THEME_ID, [], true))) {
+ it.each([DEFAULT_CURSOR_THEME_ID, "prism-glow"])("leaves %s to the extruded sprite in 3D", (id) => {
+ for (const sprite of Object.values(resolveCursorSprites(id, [], true))) {
expect(sprite.sculpt).toBeUndefined();
}
});
diff --git a/src/lib/cursor/cursorThemes.ts b/src/lib/cursor/cursorThemes.ts
index ada3ee416..01e565118 100644
--- a/src/lib/cursor/cursorThemes.ts
+++ b/src/lib/cursor/cursorThemes.ts
@@ -136,7 +136,8 @@ export function readCursorAsArrow(
* To add one: drop arrow.png/pointer.png into public/cursors/<id>/ and add an entry here
* with hotspots normalized to the 32-logical reference (divide a 128px-pack hotspot by 4).
* Mark an asset `sculpted` when the compositor has a 3D model for it (`sculpt.rs`); other states
- * are extruded from their sprite in 3D. An id that leaves this list reads back as the default art
+ * are extruded from their sprite in 3D, and so is all of Prism Glow, whose faceted art reads
+ * best as it is drawn. An id that leaves this list reads back as the default art
* through `normalizeCursorThemeId`, so a project saved with it still opens.
*/
export const CURSOR_THEMES: readonly CursorTheme[] = [
@@ -172,7 +173,6 @@ export const CURSOR_THEMES: readonly CursorTheme[] = [
height: 32,
hotspotX: 6.3456,
hotspotY: 2.0672,
- sculpted: true,
},
pointer: {
assetPath: "cursors/prism-glow/pointer.png",
@@ -180,7 +180,6 @@ export const CURSOR_THEMES: readonly CursorTheme[] = [
height: 32,
hotspotX: 11.968,
hotspotY: 2.0352,
- sculpted: true,
},
},
},