feat(site): 리퀴드 글래스 굴절을 올바른 변위 지도로 다시 붙인다
All checks were successful
ci / build (push) Successful in 29s
All checks were successful
ci / build (push) Successful in 29s
앞선 커밋에서 "backdrop-filter 체인에서 displacement 가 안 먹는다" 고 적고 데모를 뺐다. 틀렸다. svg-filters.md 에 이미 적혀 있던 두 규칙을 안 지킨 것이다. - 변위 지도는 노이즈가 아니다. feTurbulence 로 만들면 값이 중립(128)으로 수렴해 scale 을 아무리 키워도 곱해지는 값이 0 이다. - feImage 의 크기는 요소 크기와 같아야 한다. 자동으로 안 맞춰준다. 가장자리에서 안쪽으로 미는 그라디언트를 직접 그렸다. linearGradient 한 장으로는 R 과 G 를 따로 못 만들므로 지도를 두 장 놓고 displacement 를 두 번 건다. 쓰지 않는 축에는 128 고정인 B 채널을 물려 이동량을 0 으로 만든다. 실측: 평균 채널차 1.66(난류 지도) → 9.29(그린 지도), 최대 126. 배경에 격자를 깔아 확인했다 — 패널 가장자리에서 격자 셀이 눌린다. svg-filters.md 에 지도 두 장 기법과 확인 방법을 기록했다.
This commit is contained in:
parent
ae2980872b
commit
9a09678dee
4 changed files with 154 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
import { Image } from "astro:assets";
|
||||
import paper from "../assets/bg/bg-paper.webp";
|
||||
import split from "../assets/bg/bg-split.webp";
|
||||
|
||||
/**
|
||||
* 필터 데모의 소재. 같은 소재를 두 번 그리고 한쪽에만 필터를 건다.
|
||||
|
|
@ -8,7 +9,7 @@ import paper from "../assets/bg/bg-paper.webp";
|
|||
* 보이는 차이가 필터 때문인지 소재 때문인지 알 수 없다.
|
||||
*/
|
||||
interface Props {
|
||||
kind: "scrim" | "cvd" | "goo";
|
||||
kind: "scrim" | "cvd" | "goo" | "glass";
|
||||
on: boolean;
|
||||
}
|
||||
const { kind, on } = Astro.props;
|
||||
|
|
@ -48,6 +49,18 @@ const { kind, on } = Astro.props;
|
|||
)
|
||||
}
|
||||
|
||||
{
|
||||
kind === "glass" && (
|
||||
<div class="art art-glass">
|
||||
<Image src={split} alt="" widths={[300, 600]} sizes="300px" loading="lazy" />
|
||||
{/* 격자를 함께 깐다. 굴절은 직선이 휘어야 보인다 —
|
||||
사진만 놓으면 무엇이 어떻게 밀렸는지 알 수 없다 */}
|
||||
<span class="glass-grid" />
|
||||
<span class:list={["glass-panel", { on }]}>산미 8.5</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
<style>
|
||||
.art {
|
||||
height: var(--art-h, 118px);
|
||||
|
|
@ -130,6 +143,42 @@ const { kind, on } = Astro.props;
|
|||
}
|
||||
|
||||
|
||||
/* ---- 유리 ----------------------------------------------------
|
||||
feImage 는 요소 크기에 맞춰 자동 조정되지 않는다.
|
||||
그래서 패널 크기를 필터의 지도 크기(216×72)와 똑같이 고정한다 */
|
||||
.art-glass :global(img) {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.glass-grid {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
repeating-linear-gradient(90deg, rgb(255 255 255 / 0.5) 0 1px, transparent 1px 20px),
|
||||
repeating-linear-gradient(0deg, rgb(255 255 255 / 0.5) 0 1px, transparent 1px 20px);
|
||||
}
|
||||
.glass-panel {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 216px;
|
||||
height: 72px;
|
||||
margin: -36px 0 0 -108px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid rgb(255 255 255 / 0.28);
|
||||
background: rgb(255 255 255 / 0.05);
|
||||
color: #fff;
|
||||
font-weight: var(--weight-medium);
|
||||
/* 굴절을 못 읽는 엔진은 여기서 멈춘다 */
|
||||
backdrop-filter: blur(1px);
|
||||
}
|
||||
.glass-panel.on { backdrop-filter: blur(1px) url(#f-lens); }
|
||||
|
||||
@media (prefers-reduced-transparency: reduce) {
|
||||
.cap { text-shadow: 0 1px 3px rgb(0 0 0 / 0.9); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,26 @@ import type { Content } from "../i18n/content";
|
|||
|
||||
interface Props { c: Content["materials"]; }
|
||||
const { c } = Astro.props;
|
||||
|
||||
/* 변위 지도 두 장. 가장자리에서 안쪽으로 미는 값만 담고 가운데는 중립(128)이다.
|
||||
`#` 이 data URI 를 끊으므로 색은 rgb() 로 적는다. */
|
||||
const W = 216;
|
||||
const H = 72;
|
||||
const map = (vertical: boolean, from: string, to: string) => {
|
||||
const dir = vertical ? 'x1="0" y1="0" x2="0" y2="1"' : 'x1="0" y1="0" x2="1" y2="0"';
|
||||
const svg =
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}">` +
|
||||
`<defs><linearGradient id="g" ${dir}>` +
|
||||
`<stop offset="0" stop-color="${from}"/>` +
|
||||
`<stop offset="0.30" stop-color="rgb(128,128,128)"/>` +
|
||||
`<stop offset="0.70" stop-color="rgb(128,128,128)"/>` +
|
||||
`<stop offset="1" stop-color="${to}"/>` +
|
||||
`</linearGradient></defs>` +
|
||||
`<rect width="${W}" height="${H}" fill="url(#g)"/></svg>`;
|
||||
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
||||
};
|
||||
const MAP_X = map(false, "rgb(255,128,128)", "rgb(0,128,128)");
|
||||
const MAP_Y = map(true, "rgb(128,255,128)", "rgb(128,0,128)");
|
||||
---
|
||||
|
||||
{/*
|
||||
|
|
@ -113,6 +133,28 @@ const { c } = Astro.props;
|
|||
<feComposite in="SourceGraphic" in2="goo" operator="atop" />
|
||||
</filter>
|
||||
|
||||
|
||||
<!--
|
||||
리퀴드 글래스. 변위 지도는 **노이즈가 아니다** — 유리는 무작위로 휘지 않고
|
||||
가장자리에서 안쪽으로 휜다. feTurbulence 로 만들면 지도가 중립값(128)으로
|
||||
수렴해 scale 을 아무리 키워도 아무 일도 안 일어난다(실측: 채널차 1.66).
|
||||
|
||||
R 채널이 X, G 채널이 Y 이동량이고 128 이 "움직이지 마라" 다.
|
||||
한 장의 그라디언트로 R 과 G 를 따로 만들 수 없으니, 지도 두 장을 놓고
|
||||
displacement 를 두 번 건다. 안 쓰는 축은 B(=128 고정)를 물려 0 으로 만든다.
|
||||
|
||||
feImage 의 width/height 는 요소 크기와 같아야 한다 — 자동으로 안 맞춰준다.
|
||||
그래서 이 패널만 크기를 고정해 뒀다.
|
||||
-->
|
||||
<filter id="f-lens" color-interpolation-filters="sRGB"
|
||||
x="0" y="0" width="100%" height="100%">
|
||||
<feImage href={MAP_X} x="0" y="0" width="216" height="72" result="mx" />
|
||||
<feDisplacementMap in="SourceGraphic" in2="mx" scale="30"
|
||||
xChannelSelector="R" yChannelSelector="B" result="dx" />
|
||||
<feImage href={MAP_Y} x="0" y="0" width="216" height="72" result="my" />
|
||||
<feDisplacementMap in="dx" in2="my" scale="30"
|
||||
xChannelSelector="B" yChannelSelector="G" />
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue