BlueGit

timfa kwin-marble

Keep KVT logo aspect correct during window↔marble morph

Logo UVs used q=p/b, so a non-square half-size stretched the mark
while e∈(0,1). Sample through isotropic p/min(b) (equals q when the
marble is square) and keep ~1px Energise-style SDF AA. No extra
samples or uniforms; final marble look unchanged.

timfa Tim Falken · pushed by timfa

Authored 2026-11-06 · 11 days ago

Hash
af5a52b9b6adbbd6a24619b10a74d9f753dc9905
Parent
11767763
4 files changed +36 −28
kwin6_effect_marble/contents/shaders/marble.frag +9 −7
@@ -1023,16 +1023,18 @@ void main() {
1023 1023 {
1024 1024 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1025 1025 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1026 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1027 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1028 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1026 1029 const float logoScale = 0.50;
1027 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1030 float qRef = max(min(b.x, b.y), 1.0);
1031 vec2 qLogo = p / qRef;
1032 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1028 1033 float logoMask = 0.0;
1029 1034 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1030 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1031 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1032 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1033 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1034 // with ~1.5 screen px of SDF AA.
1035 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1035 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1036 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1037 float aa = 1.0 * logoScale / qRef;
1036 1038 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1037 1039 }
1038 1040 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
@@ -1023,16 +1023,18 @@ void main() {
1023 {
1023 {
1024 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1024 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1025 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1025 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1026 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1027 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1028 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1026 const float logoScale = 0.50;
1029 const float logoScale = 0.50;
1027 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1030 float qRef = max(min(b.x, b.y), 1.0);
1031 vec2 qLogo = p / qRef;
1032 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1028 float logoMask = 0.0;
1033 float logoMask = 0.0;
1029 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1034 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1030 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1035 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1031 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1036 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1032 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1037 float aa = 1.0 * logoScale / qRef;
1033 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1034 // with ~1.5 screen px of SDF AA.
1035 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1036 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1038 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1037 }
1039 }
1038 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
1040 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
kwin6_effect_marble/contents/shaders/marble_core.frag +9 −7
@@ -1024,16 +1024,18 @@ void main() {
1024 1024 {
1025 1025 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1026 1026 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1027 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1028 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1029 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1027 1030 const float logoScale = 0.50;
1028 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1031 float qRef = max(min(b.x, b.y), 1.0);
1032 vec2 qLogo = p / qRef;
1033 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1029 1034 float logoMask = 0.0;
1030 1035 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1031 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1032 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1033 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1034 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1035 // with ~1.5 screen px of SDF AA.
1036 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1036 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1037 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1038 float aa = 1.0 * logoScale / qRef;
1037 1039 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1038 1040 }
1039 1041 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
@@ -1024,16 +1024,18 @@ void main() {
1024 {
1024 {
1025 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1025 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1026 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1026 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1027 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1028 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1029 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1027 const float logoScale = 0.50;
1030 const float logoScale = 0.50;
1028 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1031 float qRef = max(min(b.x, b.y), 1.0);
1032 vec2 qLogo = p / qRef;
1033 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1029 float logoMask = 0.0;
1034 float logoMask = 0.0;
1030 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1035 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1031 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1036 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1032 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1037 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1033 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1038 float aa = 1.0 * logoScale / qRef;
1034 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1035 // with ~1.5 screen px of SDF AA.
1036 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1037 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1039 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1038 }
1040 }
1039 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
1041 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
kwin6_effect_marble_minimize/contents/shaders/marble.frag +9 −7
@@ -1023,16 +1023,18 @@ void main() {
1023 1023 {
1024 1024 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1025 1025 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1026 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1027 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1028 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1026 1029 const float logoScale = 0.50;
1027 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1030 float qRef = max(min(b.x, b.y), 1.0);
1031 vec2 qLogo = p / qRef;
1032 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1028 1033 float logoMask = 0.0;
1029 1034 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1030 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1031 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1032 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1033 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1034 // with ~1.5 screen px of SDF AA.
1035 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1035 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1036 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1037 float aa = 1.0 * logoScale / qRef;
1036 1038 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1037 1039 }
1038 1040 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
@@ -1023,16 +1023,18 @@ void main() {
1023 {
1023 {
1024 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1024 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1025 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1025 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1026 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1027 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1028 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1026 const float logoScale = 0.50;
1029 const float logoScale = 0.50;
1027 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1030 float qRef = max(min(b.x, b.y), 1.0);
1031 vec2 qLogo = p / qRef;
1032 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1028 float logoMask = 0.0;
1033 float logoMask = 0.0;
1029 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1034 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1030 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1035 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1031 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1036 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1032 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1037 float aa = 1.0 * logoScale / qRef;
1033 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1034 // with ~1.5 screen px of SDF AA.
1035 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1036 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1038 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1037 }
1039 }
1038 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
1040 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
kwin6_effect_marble_minimize/contents/shaders/marble_core.frag +9 −7
@@ -1024,16 +1024,18 @@ void main() {
1024 1024 {
1025 1025 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1026 1026 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1027 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1028 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1029 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1027 1030 const float logoScale = 0.50;
1028 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1031 float qRef = max(min(b.x, b.y), 1.0);
1032 vec2 qLogo = p / qRef;
1033 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1029 1034 float logoMask = 0.0;
1030 1035 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1031 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1032 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1033 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1034 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1035 // with ~1.5 screen px of SDF AA.
1036 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1036 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1037 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1038 float aa = 1.0 * logoScale / qRef;
1037 1039 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1038 1040 }
1039 1041 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
@@ -1024,16 +1024,18 @@ void main() {
1024 {
1024 {
1025 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1025 // Larger scale => smaller on-marble mark; y offset lowers it so top dots stay inside.
1026 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1026 // q.y > 0 is marble bottom (Energise SVG y-down); subtracting logoUV.y moves the mark down.
1027 // q = p/b stretches with non-square half-size during morph; map logo through isotropic
1028 // px space (inscribed-square of b) so aspect stays correct while window≠marble. When
1029 // e→1, b is square (R0,R0) so qLogo≡q — final marble unchanged.
1027 const float logoScale = 0.50;
1030 const float logoScale = 0.50;
1028 vec2 logoUV = 0.5 + q * logoScale - vec2(0.0, 0.075);
1031 float qRef = max(min(b.x, b.y), 1.0);
1032 vec2 qLogo = p / qRef;
1033 vec2 logoUV = 0.5 + qLogo * logoScale - vec2(0.0, 0.075);
1029 float logoMask = 0.0;
1034 float logoMask = 0.0;
1030 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1035 if (logoUV.x > 0.16 && logoUV.x < 0.84 && logoUV.y > 0.02 && logoUV.y < 0.99) {
1031 // Energise sampleLingerMask: aa ~= N / sizeInPxOfLogoUV. Here logoUV spans the marble
1036 // Energise-style ~1.0px SDF AA; d(logoUV)/d(px)=logoScale/qRef (isotropic).
1032 // via q*logoScale and q=p/b, so d(logoUV)/d(px)=logoScale/b. Old aa=2.5/b ignored that
1037 // 1.0 keeps a 1px softstep (was 1.5≈3px band); safer than subpixel hard edges on ~60px marbles.
1033 // factor and always made a ~10px softstep — wider than the dots on a ~55px marble, so
1038 float aa = 1.0 * logoScale / qRef;
1034 // even feature centres never reached full mask (live "vervaagd" mush). Match Energise
1035 // with ~1.5 screen px of SDF AA.
1036 float aa = 1.5 * logoScale / max(min(b.x, b.y), 1.0);
1037 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1039 logoMask = smoothstep(aa, -aa, logoSD(logoUV));
1038 }
1040 }
1039 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.
1041 // Shadow dissolve via lit (kept); geometric mask stays sharp from corrected aa above.