f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
171 lines
5.2 KiB
Markdown
171 lines
5.2 KiB
Markdown
---
|
||
id: wiki-2026-0508-에일리어싱-aliasing
|
||
title: 에일리어싱 (Aliasing)
|
||
category: 10_Wiki/Topics
|
||
status: verified
|
||
canonical_id: self
|
||
aliases: [Aliasing, 계단현상, Jaggies]
|
||
duplicate_of: none
|
||
source_trust_level: A
|
||
confidence_score: 0.9
|
||
verification_status: applied
|
||
tags: [graphics, rendering, frontend, antialiasing]
|
||
raw_sources: []
|
||
last_reinforced: 2026-05-10
|
||
github_commit: pending
|
||
tech_stack:
|
||
language: CSS/JS
|
||
framework: Canvas/WebGL
|
||
---
|
||
|
||
# 에일리어싱 (Aliasing)
|
||
|
||
## 매 한 줄
|
||
> **"매 sampling rate 가 signal frequency 의 절반 미만일 때 발생하는 distortion"**. Nyquist theorem 위반 의 결과로, frontend 에서 매 jagged edges, moiré patterns, shimmer 형태로 나타남. 매 antialiasing (AA) 기법으로 완화.
|
||
|
||
## 매 핵심
|
||
|
||
### 매 정의
|
||
- **Spatial aliasing**: 매 jagged edges (계단 현상) — pixel grid 가 매 diagonal/curved line 의 표현 부족.
|
||
- **Temporal aliasing**: 매 frame rate 부족 의 결과 — wagon-wheel effect, stutter.
|
||
- **Texture aliasing**: 매 minification 시 매 moiré pattern.
|
||
|
||
### 매 원인
|
||
- **Discrete sampling**: 매 continuous signal 을 discrete pixel 로 sampling.
|
||
- **Sub-pixel detail**: 매 single pixel 보다 작은 detail 의 미손실 표현 불가.
|
||
- **Nyquist criterion**: 매 sampling_rate ≥ 2 × max_frequency 충족 X.
|
||
|
||
### 매 응용 (frontend)
|
||
1. **Canvas/WebGL rendering**: 매 line, polygon, font 의 smooth rendering.
|
||
2. **CSS transforms**: 매 rotated/scaled element 의 edge.
|
||
3. **SVG icons**: 매 small size 매 shimmer 방지.
|
||
|
||
## 💻 패턴
|
||
|
||
### Canvas 2D antialiasing 활성화
|
||
```javascript
|
||
const canvas = document.querySelector('canvas');
|
||
const ctx = canvas.getContext('2d');
|
||
|
||
// imageSmoothingEnabled: 매 default true
|
||
ctx.imageSmoothingEnabled = true;
|
||
ctx.imageSmoothingQuality = 'high'; // 'low' | 'medium' | 'high'
|
||
|
||
ctx.drawImage(img, 0, 0, 100, 100);
|
||
```
|
||
|
||
### WebGL MSAA (Multi-Sample Anti-Aliasing)
|
||
```javascript
|
||
const gl = canvas.getContext('webgl2', {
|
||
antialias: true, // 매 MSAA 활성화 (browser 가 sample count 결정)
|
||
});
|
||
|
||
// 매 explicit sample count (offscreen framebuffer)
|
||
const fb = gl.createFramebuffer();
|
||
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
|
||
const rb = gl.createRenderbuffer();
|
||
gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
|
||
gl.renderbufferStorageMultisample(
|
||
gl.RENDERBUFFER, 4, gl.RGBA8, width, height
|
||
);
|
||
```
|
||
|
||
### CSS — 매 transform 시 jagged edge 완화
|
||
```css
|
||
.rotated {
|
||
transform: rotate(15deg);
|
||
/* 매 GPU 가속 + subpixel AA */
|
||
will-change: transform;
|
||
backface-visibility: hidden;
|
||
-webkit-font-smoothing: antialiased;
|
||
-moz-osx-font-smoothing: grayscale;
|
||
}
|
||
|
||
/* 매 image scaling 시 quality */
|
||
img {
|
||
image-rendering: auto; /* 매 default — browser AA */
|
||
/* image-rendering: pixelated; — 매 retro pixel art */
|
||
/* image-rendering: crisp-edges; — 매 sharp without AA */
|
||
}
|
||
```
|
||
|
||
### SVG — 매 sub-pixel rendering
|
||
```html
|
||
<!-- 매 매끈한 line: shape-rendering -->
|
||
<svg viewBox="0 0 100 100">
|
||
<line
|
||
x1="10" y1="10" x2="90" y2="50"
|
||
stroke="black"
|
||
shape-rendering="geometricPrecision"
|
||
/>
|
||
<!-- "geometricPrecision" | "crispEdges" | "auto" -->
|
||
</svg>
|
||
```
|
||
|
||
### Three.js — 매 FXAA postprocessing
|
||
```javascript
|
||
import * as THREE from 'three';
|
||
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
||
import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
|
||
import { FXAAShader } from 'three/addons/shaders/FXAAShader.js';
|
||
|
||
const composer = new EffectComposer(renderer);
|
||
const fxaa = new ShaderPass(FXAAShader);
|
||
fxaa.material.uniforms.resolution.value.set(
|
||
1 / window.innerWidth, 1 / window.innerHeight
|
||
);
|
||
composer.addPass(fxaa);
|
||
```
|
||
|
||
### Devicepixelratio 보정
|
||
```javascript
|
||
function setupHiDPICanvas(canvas) {
|
||
const dpr = window.devicePixelRatio || 1;
|
||
const rect = canvas.getBoundingClientRect();
|
||
|
||
canvas.width = rect.width * dpr;
|
||
canvas.height = rect.height * dpr;
|
||
canvas.style.width = `${rect.width}px`;
|
||
canvas.style.height = `${rect.height}px`;
|
||
|
||
const ctx = canvas.getContext('2d');
|
||
ctx.scale(dpr, dpr);
|
||
return ctx;
|
||
}
|
||
```
|
||
|
||
## 매 결정 기준
|
||
| 상황 | Approach |
|
||
|---|---|
|
||
| 매 SVG icon, vector | shape-rendering="geometricPrecision" |
|
||
| 매 retina display | devicePixelRatio scaling |
|
||
| 매 WebGL game | MSAA 4x or FXAA postprocess |
|
||
| 매 pixel art | image-rendering: pixelated (AA 끄기) |
|
||
| 매 rotated text | -webkit-font-smoothing: antialiased |
|
||
|
||
**기본값**: 매 antialias: true 활성화 + DPR scaling 적용.
|
||
|
||
## 🔗 Graph
|
||
- 부모: [[Computer Graphics]]
|
||
- 변형: [[FXAA]]
|
||
- 응용: [[WebGL]] · [[SVG]]
|
||
|
||
## 🤖 LLM 활용
|
||
**언제**: 매 Canvas/WebGL rendering 매 jagged edge 의 완화, retina display 의 sharp output.
|
||
**언제 X**: 매 pixel art (의도적 jagged), 매 ultra low-end GPU (AA 비용 부담).
|
||
|
||
## ❌ 안티패턴
|
||
- **DPR 무시**: 매 retina 매 blurry — devicePixelRatio scaling 누락.
|
||
- **AA 항상 max**: 매 mobile GPU 매 fps 저하 — adaptive quality 필요.
|
||
- **transform 후 sub-pixel position**: 매 0.5px offset 매 blur — translateZ(0) hack.
|
||
|
||
## 🧪 검증 / 중복
|
||
- Verified (MDN Canvas API, WebGL spec, Three.js docs).
|
||
- 신뢰도 A.
|
||
|
||
## 🕓 Changelog
|
||
| 날짜 | 변경 |
|
||
|---|---|
|
||
| 2026-05-08 | Phase 1 |
|
||
| 2026-05-10 | Manual cleanup — aliasing, AA techniques (MSAA/FXAA), Canvas/WebGL/SVG/CSS 패턴 정리 |
|