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): anti-alias the inner edges of the 3D cursors
Claudeef941a53ee9c
diff --git a/crates/compositor/src/compositor_linux.rs b/crates/compositor/src/compositor_linux.rsindex bcc7f1671..f772496b0 100644--- a/crates/compositor/src/compositor_linux.rs+++ b/crates/compositor/src/compositor_linux.rs@@ -5744,7 +5744,8 @@ mod tests {/// fleche comme sur la main, le modele est pour une bonne part de la couleur du trait (le/// plateau, le jonc, les rainures entre les doigts), autour de la couleur du corps, et montre/// ce qu'il porte devant : l'etoile jaune de Star Sprout, le calque et les tirets jaunes de la- /// fleche de Pop Coral, les tirets corail de sa main.+ /// fleche de Pop Coral, les tirets corail de sa main. Les parts comptent les pixels francs :+ /// ceux que l'antialiasing mêle aux bords n'entrent dans aucune.#[test]fn the_rimmed_models_keep_the_outline_of_their_art() {type Rgb = [i32; 3];@@ -5759,7 +5760,7 @@ mod tests {("studio-ink", "arrow", &black, &ivory, &|_| false, [0.3, 0.15, 0.0]),("studio-ink", "pointer", &black, &ivory, &|_| false, [0.2, 0.3, 0.0]),("pop-coral", "arrow", &navy, &coral, &yellow, [0.2, 0.2, 0.05]),- ("pop-coral", "pointer", &navy, &yellow, &coral, [0.2, 0.3, 0.02]),+ ("pop-coral", "pointer", &navy, &yellow, &coral, [0.18, 0.3, 0.02]),("star-sprout", "arrow", &navy, &mint, &yellow, [0.25, 0.2, 0.03]),("star-sprout", "pointer", &navy, &ivory, &yellow, [0.25, 0.2, 0.03]),];diff --git a/crates/compositor/src/shaders.hlsl b/crates/compositor/src/shaders.hlslindex 32eac4df9..339536523 100644--- a/crates/compositor/src/shaders.hlsl+++ b/crates/compositor/src/shaders.hlsl@@ -1584,7 +1584,12 @@ static const int STAGE_NORMAL = 1; // quatre sondes en tétraèdre autour du poistatic const int STAGE_AO = 2; // cinq sondes le long de la normale, jusqu'à 0,08 du prototypestatic const int STAGE_SELF = 3; // pénombre du modèle sur lui-même, vers la lampe (32 pas)static const int STAGE_PLANE = 4; // le point du plan : son contact, puis sa pénombre (32 pas)-static const int STAGE_DONE = 5;+static const int STAGE_EDGE = 5; // quatre sondes à un demi-pixel du point touché : un bord ?+static const int STAGE_SHADE = 6; // l'ombrage d'un échantillon, puis le rayon suivant s'il en reste+static const int STAGE_DONE = 7;++// Les trois rayons de plus d'un pixel au bord, en pixels autour de son centre.+static const float2 MODEL_SUBPIXEL[3] = { float2(0.35, 0.2), float2(-0.35, 0.2), float2(0.0, -0.4) };// Sonde `k` de la normale, sommet d'un tétraèdre.float3 model_tetra(int k)@@ -1625,8 +1630,14 @@ float4 cursor_model(float2 local)float3 lamp = float3(color.rg + sprite_size() * 0.5, 0.0) + l * SCULPT_LAMP_DIST;// Silhouette antialiasée : un rayon qui frôle le modèle à moins d'un pixel le couvre en partie- // (`best`, la plus petite distance rencontrée, en pixels).- float2 tb = ray_box(ro, rd, lo - 0.02, hi + 0.02);+ // (`best`, la plus petite distance rencontrée, en pixels). Les bords intérieurs (deux matières,+ // une arête, un arrondi serré) sont suréchantillonnés : `STAGE_EDGE` sonde le modèle à un+ // demi-pixel du point touché, dans son plan tangent ; si la matière change ou que la surface+ // s'écarte, trois rayons de plus (`MODEL_SUBPIXEL`) sont marchés et ombrés, avec l'occlusion et+ // les ombres du premier. Chaque échantillon passe par `STAGE_SHADE`, seul appel de+ // `model_shade` ; le pixel est leur moyenne.+ float3 ray = rd;+ float2 tb = ray_box(ro, ray, lo - 0.02, hi + 0.02);int stage = tb.x < tb.y && tb.y > 0.0 ? STAGE_MARCH : STAGE_DONE;// Le point du plan derrière le pixel est à régler avant le prochain tour.bool plane_next = stage == STAGE_DONE;@@ -1634,8 +1645,10 @@ float4 cursor_model(float2 local)float t = max(tb.x, 0.0);float best = 1e9;float t_best = t;+ float d_best = 0.0;float mat = 0.0;float cov = 0.0;+ float cov_s = 0.0;float3 q = 0.0;float3 n = 0.0;float3 L = 0.0;@@ -1649,14 +1662,19 @@ float4 cursor_model(float2 local)float inside = 0.0;float contact = 0.0;float dropped = 0.0;- [loop] for (int it = 0; it < 180; it++)+ // Sous-échantillons restants, échantillons ombrés, et leur somme (couleur × couverture,+ // couverture).+ int sub = 0;+ int shaded = 0;+ float4 acc = 0.0;+ [loop] for (int it = 0; it < 500; it++){if (plane_next){// Le plan, là où le modèle ne couvre pas tout le pixel : ombre portée et ombre de// contact, seulement à l'intérieur de l'écran (`mb.xy` = sa demi-taille, px du plan).plane_next = false;- stage = STAGE_DONE;+ stage = cov > 0.0 ? STAGE_SHADE : STAGE_DONE;float denom = dot(rd, nz);if (cov < 1.0 && denom < -1e-4){@@ -1671,15 +1689,54 @@ float4 cursor_model(float2 local)}}}+ if (stage == STAGE_SHADE)+ {+ if (cov_s > 0.0)+ {+ float3 tl = lamp - q;+ float fall = SCULPT_LAMP_DIST * SCULPT_LAMP_DIST / dot(tl, tl);+ float3 c = model_shade(q, n, ray, normalize(tl), fall, sh, ao, mat, l, fill);+ acc += float4(c * cov_s, cov_s);+ }+ shaded++;+ stage = STAGE_DONE;+ if (sub > 0)+ {+ // Le rayon suivant, décalé dans le pixel ; il repart de sa propre entrée dans la+ // boîte, pour ne pas manquer ce qui passerait devant le premier.+ float3 dws = float3(local + MODEL_SUBPIXEL[3 - sub] + src.xy, -persp);+ sub--;+ dlen = length(dws);+ ray = plane_to_model(world_to_plane(dws / dlen, f), f);+ tb = ray_box(ro, ray, lo - 0.02, hi + 0.02);+ cov_s = 0.0;+ stage = STAGE_SHADE;+ if (tb.x < tb.y && tb.y > 0.0)+ {+ stage = STAGE_MARCH;+ k = 0;+ t = max(tb.x, 0.0);+ best = 1e9;+ t_best = t;+ }+ }+ continue;+ }float3 pos;if (stage == STAGE_MARCH){- pos = ro + rd * t;+ pos = ro + ray * t;}else if (stage == STAGE_NORMAL){pos = q + 0.002 * model_tetra(k);}+ else if (stage == STAGE_EDGE)+ {+ float3 side = normalize(cross(n, ray));+ float3 e = (k >= 2 ? cross(n, side) : side) * (k % 2 == 1 ? -1.0 : 1.0);+ pos = q + e * 0.5 * t_best / dlen;+ }else if (stage == STAGE_AO){pos = q + (0.01 + 0.0175 * k) * SCULPT_SCALE * n;@@ -1706,22 +1763,38 @@ float4 cursor_model(float2 local){best = hit ? 0.0 : d / fp;t_best = t;+ d_best = d;mat = m.y;}t += d * stride;k++;if (hit || t > tb.y || k == 96){- cov = saturate(1.0 - best);- if (cov > 0.0)+ cov_s = saturate(1.0 - best);+ if (shaded > 0){- q = ro + rd * t_best;- stage = STAGE_NORMAL;- k = 0;+ stage = STAGE_SHADE;+ if (cov_s > 0.0)+ {+ q = ro + ray * t_best;+ n = 0.0;+ stage = STAGE_NORMAL;+ k = 0;+ }}else{- plane_next = true;+ cov = cov_s;+ if (cov > 0.0)+ {+ q = ro + ray * t_best;+ stage = STAGE_NORMAL;+ k = 0;+ }+ else+ {+ plane_next = true;+ }}}}@@ -1732,6 +1805,21 @@ float4 cursor_model(float2 local)if (k == 4){n = normalize(n);+ k = 0;+ stage = shaded > 0 ? STAGE_SHADE : STAGE_EDGE;+ }+ }+ else if (stage == STAGE_EDGE)+ {+ // Autre matière, ou surface qui s'écarte du plan tangent de plus de 2 % d'un pixel+ // (le point touché flotte déjà de `d_best` au-dessus d'elle).+ if (m.y != mat || abs(d - d_best) > 0.02 * t_best / dlen)+ {+ sub = 3;+ }+ k++;+ if (k == 4)+ {stage = STAGE_AO;k = 0;ao = 0.0;@@ -1782,7 +1870,7 @@ float4 cursor_model(float2 local)k = 1;if (!(tbp.x < tbp.y && tbp.y > 0.0)){- stage = STAGE_DONE;+ stage = cov > 0.0 ? STAGE_SHADE : STAGE_DONE;}}else@@ -1794,21 +1882,15 @@ float4 cursor_model(float2 local){res = saturate(res);dropped = 1.0 - res * res * (3.0 - 2.0 * res);- stage = STAGE_DONE;+ stage = cov > 0.0 ? STAGE_SHADE : STAGE_DONE;}}}- float3 rgb = 0.0;- if (cov > 0.0)- {- float3 tl = lamp - q;- float fall = SCULPT_LAMP_DIST * SCULPT_LAMP_DIST / dot(tl, tl);- rgb = model_shade(q, n, rd, normalize(tl), fall, sh, ao, mat, l, fill);- }+ float w = 1.0 / max(shaded, 1);float shadow = inside * max(dropped * MODEL_SHADOW_ALPHA, contact * MODEL_CONTACT_ALPHA);- float a = cov * color.a;- return float4(rgb * a, a + (1.0 - a) * shadow * color.a); // prémultiplié, ombre noire+ float a = acc.a * w * color.a;+ return float4(acc.rgb * w * color.a, a + (1.0 - a) * shadow * color.a); // prémultiplié, ombre noire}// ============ Impact du clic (mode 16) ============diff --git a/crates/compositor/src/shaders.metal b/crates/compositor/src/shaders.metalindex a8d64cb80..3f64c3119 100644--- a/crates/compositor/src/shaders.metal+++ b/crates/compositor/src/shaders.metal@@ -1447,7 +1447,11 @@ constant int STAGE_NORMAL = 1;constant int STAGE_AO = 2;constant int STAGE_SELF = 3;constant int STAGE_PLANE = 4;-constant int STAGE_DONE = 5;+constant int STAGE_EDGE = 5;+constant int STAGE_SHADE = 6;+constant int STAGE_DONE = 7;++constant float2 MODEL_SUBPIXEL[3] = { float2(0.35, 0.2), float2(-0.35, 0.2), float2(0.0, -0.4) };inline float3 model_tetra(int k){@@ -1483,15 +1487,18 @@ static float4 cursor_model(float2 local, constant Layer &layer,float stride = sculpt_id(layer) > 0 ? 0.85 : 1.0;float3 lamp = float3(layer.color.rg + sprite_size(layer) * 0.5, 0.0) + l * SCULPT_LAMP_DIST;- float2 tb = ray_box(ro, rd, lo - 0.02, hi + 0.02);+ float3 ray = rd;+ float2 tb = ray_box(ro, ray, lo - 0.02, hi + 0.02);int stage = tb.x < tb.y && tb.y > 0.0 ? STAGE_MARCH : STAGE_DONE;bool plane_next = stage == STAGE_DONE;int k = 0;float t = max(tb.x, 0.0);float best = 1e9;float t_best = t;+ float d_best = 0.0;float mat = 0.0;float cov = 0.0;+ float cov_s = 0.0;float3 q = float3(0.0);float3 n = float3(0.0);float3 L = float3(0.0);@@ -1503,12 +1510,15 @@ static float4 cursor_model(float2 local, constant Layer &layer,float inside = 0.0;float contact = 0.0;float dropped = 0.0;- for (int it = 0; it < 180; it++)+ int sub = 0;+ int shaded = 0;+ float4 acc = float4(0.0);+ for (int it = 0; it < 500; it++){if (plane_next){plane_next = false;- stage = STAGE_DONE;+ stage = cov > 0.0 ? STAGE_SHADE : STAGE_DONE;float denom = dot(rd, nz);if (cov < 1.0 && denom < -1e-4){@@ -1523,18 +1533,55 @@ static float4 cursor_model(float2 local, constant Layer &layer,}}}+ if (stage == STAGE_SHADE)+ {+ if (cov_s > 0.0)+ {+ float3 tl = lamp - q;+ float fall = SCULPT_LAMP_DIST * SCULPT_LAMP_DIST / dot(tl, tl);+ float3 c = model_shade(q, n, ray, normalize(tl), fall, sh, ao, mat, l, fill, layer, texSdf, texImg);+ acc += float4(c * cov_s, cov_s);+ }+ shaded++;+ stage = STAGE_DONE;+ if (sub > 0)+ {+ float3 dws = float3(local + MODEL_SUBPIXEL[3 - sub] + layer.src.xy, -persp);+ sub--;+ dlen = length(dws);+ ray = plane_to_model(world_to_plane(dws / dlen, f), f);+ tb = ray_box(ro, ray, lo - 0.02, hi + 0.02);+ cov_s = 0.0;+ stage = STAGE_SHADE;+ if (tb.x < tb.y && tb.y > 0.0)+ {+ stage = STAGE_MARCH;+ k = 0;+ t = max(tb.x, 0.0);+ best = 1e9;+ t_best = t;+ }+ }+ continue;+ }float3 pos;if (stage == STAGE_MARCH){- pos = ro + rd * t;+ pos = ro + ray * t;}else if (stage == STAGE_NORMAL){pos = q + 0.002 * model_tetra(k);}+ else if (stage == STAGE_EDGE)+ {+ float3 side = normalize(cross(n, ray));+ float3 e = (k >= 2 ? cross(n, side) : side) * (k % 2 == 1 ? -1.0 : 1.0);+ pos = q + e * 0.5 * t_best / dlen;+ }else if (stage == STAGE_AO){- pos = q + (0.01 + 0.0175 * float(k)) * SCULPT_SCALE * n;+ pos = q + (0.01 + 0.0175 * k) * SCULPT_SCALE * n;}else if (stage == STAGE_SELF){@@ -1558,22 +1605,38 @@ static float4 cursor_model(float2 local, constant Layer &layer,{best = hit ? 0.0 : d / fp;t_best = t;+ d_best = d;mat = m.y;}t += d * stride;k++;if (hit || t > tb.y || k == 96){- cov = saturate(1.0 - best);- if (cov > 0.0)+ cov_s = saturate(1.0 - best);+ if (shaded > 0){- q = ro + rd * t_best;- stage = STAGE_NORMAL;- k = 0;+ stage = STAGE_SHADE;+ if (cov_s > 0.0)+ {+ q = ro + ray * t_best;+ n = float3(0.0);+ stage = STAGE_NORMAL;+ k = 0;+ }}else{- plane_next = true;+ cov = cov_s;+ if (cov > 0.0)+ {+ q = ro + ray * t_best;+ stage = STAGE_NORMAL;+ k = 0;+ }+ else+ {+ plane_next = true;+ }}}}@@ -1584,6 +1647,19 @@ static float4 cursor_model(float2 local, constant Layer &layer,if (k == 4){n = normalize(n);+ k = 0;+ stage = shaded > 0 ? STAGE_SHADE : STAGE_EDGE;+ }+ }+ else if (stage == STAGE_EDGE)+ {+ if (m.y != mat || abs(d - d_best) > 0.02 * t_best / dlen)+ {+ sub = 3;+ }+ k++;+ if (k == 4)+ {stage = STAGE_AO;k = 0;ao = 0.0;@@ -1591,7 +1667,7 @@ static float4 cursor_model(float2 local, constant Layer &layer,}else if (stage == STAGE_AO){- ao += ((0.01 + 0.0175 * float(k)) * SCULPT_SCALE - d) * pow(0.85, float(k));+ ao += ((0.01 + 0.0175 * k) * SCULPT_SCALE - d) * pow(0.85, float(k));k++;if (k == 5){@@ -1632,7 +1708,7 @@ static float4 cursor_model(float2 local, constant Layer &layer,k = 1;if (!(tbp.x < tbp.y && tbp.y > 0.0)){- stage = STAGE_DONE;+ stage = cov > 0.0 ? STAGE_SHADE : STAGE_DONE;}}else@@ -1644,21 +1720,15 @@ static float4 cursor_model(float2 local, constant Layer &layer,{res = saturate(res);dropped = 1.0 - res * res * (3.0 - 2.0 * res);- stage = STAGE_DONE;+ stage = cov > 0.0 ? STAGE_SHADE : STAGE_DONE;}}}- float3 rgb = float3(0.0);- if (cov > 0.0)- {- float3 tl = lamp - q;- float fall = SCULPT_LAMP_DIST * SCULPT_LAMP_DIST / dot(tl, tl);- rgb = model_shade(q, n, rd, normalize(tl), fall, sh, ao, mat, l, fill, layer, texSdf, texImg);- }+ float w = 1.0 / max(shaded, 1);float shadow = inside * max(dropped * MODEL_SHADOW_ALPHA, contact * MODEL_CONTACT_ALPHA);- float a = cov * layer.color.a;- return float4(rgb * a, a + (1.0 - a) * shadow * layer.color.a); // prémultiplié, ombre noire+ float a = acc.a * w * layer.color.a;+ return float4(acc.rgb * w * layer.color.a, a + (1.0 - a) * shadow * layer.color.a); // prémultiplié, ombre noire}// ============ Impact du clic (mode 16) ============diff --git a/crates/compositor/src/vk_shaders/layer.wgsl b/crates/compositor/src/vk_shaders/layer.wgslindex a404e29ce..0afa58748 100644--- a/crates/compositor/src/vk_shaders/layer.wgsl+++ b/crates/compositor/src/vk_shaders/layer.wgsl@@ -1388,7 +1388,11 @@ const STAGE_NORMAL: i32 = 1;const STAGE_AO: i32 = 2;const STAGE_SELF: i32 = 3;const STAGE_PLANE: i32 = 4;-const STAGE_DONE: i32 = 5;+const STAGE_EDGE: i32 = 5;+const STAGE_SHADE: i32 = 6;+const STAGE_DONE: i32 = 7;++const MODEL_SUBPIXEL = array<vec2<f32>, 3>(vec2<f32>(0.35, 0.2), vec2<f32>(-0.35, 0.2), vec2<f32>(0.0, -0.4));fn model_tetra(k: i32) -> vec3<f32> {let b = vec3<f32>(f32(((k + 3) >> 1u) & 1), f32((k >> 1u) & 1), f32(k & 1));@@ -1410,7 +1414,7 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {let hi = vec3<f32>(layer.color.rg + sprite_size(), layer.trail_a.z);let dw = vec3<f32>(local + layer.src.xy, -persp);- let dlen = length(dw);+ var dlen = length(dw);// Plan translate de mb.zw dans le repere camera (camera reelle ; 0 sous un angle fixe).let ro = plane_to_model((world_to_plane(vec3<f32>(-layer.mb.z, -layer.mb.w, persp), f) - tip) / unit, f);let rd = plane_to_model(world_to_plane(dw / dlen, f), f);@@ -1421,15 +1425,18 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {let stride = select(1.0, 0.85, sculpt_id() > 0);let lamp = vec3<f32>(layer.color.rg + sprite_size() * 0.5, 0.0) + l * SCULPT_LAMP_DIST;- let tb = ray_box(ro, rd, lo - vec3<f32>(0.02), hi + vec3<f32>(0.02));+ var ray = rd;+ var tb = ray_box(ro, ray, lo - vec3<f32>(0.02), hi + vec3<f32>(0.02));var stage = select(STAGE_DONE, STAGE_MARCH, tb.x < tb.y && tb.y > 0.0);var plane_next = stage == STAGE_DONE;var k = 0;var t = max(tb.x, 0.0);var best = 1e9;var t_best = t;+ var d_best = 0.0;var mat = 0.0;var cov = 0.0;+ var cov_s = 0.0;var q = vec3<f32>(0.0);var n = vec3<f32>(0.0);var L = vec3<f32>(0.0);@@ -1441,10 +1448,13 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {var inside = 0.0;var contact = 0.0;var dropped = 0.0;- for (var it = 0; it < 180; it++) {+ var sub = 0;+ var shaded = 0;+ var acc = vec4<f32>(0.0);+ for (var it = 0; it < 500; it++) {if plane_next {plane_next = false;- stage = STAGE_DONE;+ stage = select(STAGE_DONE, STAGE_SHADE, cov > 0.0);let denom = dot(rd, nz);if cov < 1.0 && denom < -1e-4 {g = ro + rd * ((hz - dot(ro, nz)) / denom);@@ -1457,11 +1467,42 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {}}}+ if stage == STAGE_SHADE {+ if cov_s > 0.0 {+ let tl = lamp - q;+ let fall = SCULPT_LAMP_DIST * SCULPT_LAMP_DIST / dot(tl, tl);+ let c = model_shade(q, n, ray, normalize(tl), fall, sh, ao, mat, l, fill);+ acc = acc + vec4<f32>(c * cov_s, cov_s);+ }+ shaded++;+ stage = STAGE_DONE;+ if sub > 0 {+ let dws = vec3<f32>(local + MODEL_SUBPIXEL[3 - sub] + layer.src.xy, -persp);+ sub--;+ dlen = length(dws);+ ray = plane_to_model(world_to_plane(dws / dlen, f), f);+ tb = ray_box(ro, ray, lo - vec3<f32>(0.02), hi + vec3<f32>(0.02));+ cov_s = 0.0;+ stage = STAGE_SHADE;+ if tb.x < tb.y && tb.y > 0.0 {+ stage = STAGE_MARCH;+ k = 0;+ t = max(tb.x, 0.0);+ best = 1e9;+ t_best = t;+ }+ }+ continue;+ }var pos: vec3<f32>;if stage == STAGE_MARCH {- pos = ro + rd * t;+ pos = ro + ray * t;} else if stage == STAGE_NORMAL {pos = q + 0.002 * model_tetra(k);+ } else if stage == STAGE_EDGE {+ let side = normalize(cross(n, ray));+ let e = select(side, cross(n, side), k >= 2) * select(1.0, -1.0, k % 2 == 1);+ pos = q + e * 0.5 * t_best / dlen;} else if stage == STAGE_AO {pos = q + (0.01 + 0.0175 * f32(k)) * SCULPT_SCALE * n;} else if stage == STAGE_SELF {@@ -1479,18 +1520,30 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {if hit || d / fp < best {best = select(d / fp, 0.0, hit);t_best = t;+ d_best = d;mat = m.y;}t = t + d * stride;k++;if hit || t > tb.y || k == 96 {- cov = saturate(1.0 - best);- if cov > 0.0 {- q = ro + rd * t_best;- stage = STAGE_NORMAL;- k = 0;+ cov_s = saturate(1.0 - best);+ if shaded > 0 {+ stage = STAGE_SHADE;+ if cov_s > 0.0 {+ q = ro + ray * t_best;+ n = vec3<f32>(0.0);+ stage = STAGE_NORMAL;+ k = 0;+ }} else {- plane_next = true;+ cov = cov_s;+ if cov > 0.0 {+ q = ro + ray * t_best;+ stage = STAGE_NORMAL;+ k = 0;+ } else {+ plane_next = true;+ }}}} else if stage == STAGE_NORMAL {@@ -1498,6 +1551,15 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {k++;if k == 4 {n = normalize(n);+ k = 0;+ stage = select(STAGE_EDGE, STAGE_SHADE, shaded > 0);+ }+ } else if stage == STAGE_EDGE {+ if m.y != mat || abs(d - d_best) > 0.02 * t_best / dlen {+ sub = 3;+ }+ k++;+ if k == 4 {stage = STAGE_AO;k = 0;ao = 0.0;@@ -1534,7 +1596,7 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {res = 1.0;k = 1;if !(tbp.x < tbp.y && tbp.y > 0.0) {- stage = STAGE_DONE;+ stage = select(STAGE_DONE, STAGE_SHADE, cov > 0.0);}} else {res = min(res, MODEL_SOFTNESS * d / ts.x);@@ -1543,20 +1605,15 @@ fn cursor_model(local: vec2<f32>) -> vec4<f32> {if res < 0.002 || ts.x > ts.y || k == 33 {res = saturate(res);dropped = 1.0 - res * res * (3.0 - 2.0 * res);- stage = STAGE_DONE;+ stage = select(STAGE_DONE, STAGE_SHADE, cov > 0.0);}}}- var rgb = vec3<f32>(0.0);- if cov > 0.0 {- let tl = lamp - q;- let fall = SCULPT_LAMP_DIST * SCULPT_LAMP_DIST / dot(tl, tl);- rgb = model_shade(q, n, rd, normalize(tl), fall, sh, ao, mat, l, fill);- }+ let w = 1.0 / f32(max(shaded, 1));let shadow = inside * max(dropped * MODEL_SHADOW_ALPHA, contact * MODEL_CONTACT_ALPHA);- let a = cov * layer.color.a;- return vec4<f32>(rgb * a, a + (1.0 - a) * shadow * layer.color.a); // premultiplie, ombre noire+ let a = acc.a * w * layer.color.a;+ return vec4<f32>(acc.rgb * w * layer.color.a, a + (1.0 - a) * shadow * layer.color.a); // premultiplie, ombre noire}// ---- Impact du clic (mode 16) ----diff --git a/docs/3d-effects-v2.md b/docs/3d-effects-v2.mdindex cac3e3e30..98aa45669 100644--- a/docs/3d-effects-v2.md+++ b/docs/3d-effects-v2.md@@ -312,6 +312,12 @@ face.- **Ombre sur l'écran** : celle de B.3. Les pierres et les voxels donnent de mauvaises distancesloin de leur surface (bornes de plans, champ de grille) : leur ombre vient de leur contourextrudé, le bord du trait marine pour Prism Glow, la face et l'anneau violet pour Pixel Candy.+- **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+ son plan tangent, et si la matière change ou que la surface s'en écarte, trois rayons de plus+ dans le pixel, ombrés avec l'occlusion et les ombres du premier (`STAGE_EDGE`, `STAGE_SHADE`).+ Sur un grand curseur, ~+50 % du coût du curseur (rendu logiciel), rien ailleurs.- **Coût de compilation** : FXC recopie chaque appel. La marche, les normales, l'occlusion et lesombres forment donc une seule boucle à étapes avec un seul appel au modèle, et les thèmescerclés un seul appel pour leurs deux formes.