Skip to content

Parallax Expression

레이어마다 다른 속도로 움직여 깊이감을 만드는 패럴랙스 효과입니다.

Preview

깊이(depth)에 따라 레이어 속도가 달라집니다. 가까운 레이어는 빠르게, 먼 레이어는 느리게 움직입니다.

※ 시각적 이해를 위한 애니메이션으로, 실제 결과와 다를 수 있습니다.

Code

기본 패럴랙스 (마우스/컨트롤 기반)

javascript
// Position에 적용
// 컨트롤 레이어의 위치에 따라 움직임

control = thisComp.layer("Control").transform.position;
center = [thisComp.width/2, thisComp.height/2];
depth = 0.5;  // 0 = 움직이지 않음, 1 = 컨트롤과 동일하게

offset = (control - center) * depth;
value + offset;

레이어 깊이 기반

javascript
// 레이어 순서에 따라 자동으로 깊이 결정
control = thisComp.layer("Control").transform.position;
center = [thisComp.width/2, thisComp.height/2];

// index가 클수록 뒤에 있음 (느리게)
depth = 1 / index;

offset = (control - center) * depth;
value + offset;

수평 스크롤 패럴랙스

javascript
// 컴포지션 시간에 따른 자동 스크롤
speed = 100;     // 기본 속도
depthFactor = 0.5;  // 레이어별 속도 차이

// 뒤 레이어일수록 느리게
layerSpeed = speed * Math.pow(depthFactor, index - 1);

x = value[0] - time * layerSpeed;
y = value[1];

[x, y];

Parameters

파라미터설명
depth깊이 계수 (0~1). 0이면 고정, 1이면 최대 움직임
control움직임을 제어하는 기준점
speed기본 이동 속도
depthFactor레이어별 속도 감소 비율

Examples

3단계 깊이 (전경/중경/배경)

javascript
// 각 레이어에 다른 depth 값 적용
// 전경 레이어
depth = 1.0;

// 중경 레이어
depth = 0.5;

// 배경 레이어
depth = 0.2;

control = thisComp.layer("Control").transform.position;
center = [thisComp.width/2, thisComp.height/2];
offset = (control - center) * depth;
value + offset;

마우스 따라가기 효과

javascript
// Null 레이어를 마우스 위치에 연결 후 사용
mouse = thisComp.layer("Mouse").transform.position;
center = [thisComp.width/2, thisComp.height/2];
depth = effect("Depth")("Slider") / 100;  // 슬라이더로 제어

offset = (mouse - center) * depth;
value + offset;

수직 패럴랙스 (스크롤 효과)

javascript
// Y축 스크롤에 따른 패럴랙스
scrollY = thisComp.layer("Scroll Control").transform.position[1];
baseY = thisComp.height / 2;
depth = 0.3;

yOffset = (scrollY - baseY) * depth;
[value[0], value[1] + yOffset];

Advanced

3D 패럴랙스 (스케일 포함)

javascript
// 깊이에 따라 크기도 변화
control = thisComp.layer("Control").transform.position;
center = [thisComp.width/2, thisComp.height/2];
baseDepth = 0.5;
depth = baseDepth / index;

// Position
posOffset = (control - center) * depth;
newPos = value + posOffset;

// 이 코드는 Position에, 아래는 Scale에 적용
// Scale: 100 + (depth - 0.5) * 20

회전 패럴랙스

javascript
// Rotation에 적용
control = thisComp.layer("Control").transform.position;
centerX = thisComp.width / 2;
depth = 0.1;

rotationOffset = (control[0] - centerX) * depth;
value + rotationOffset;

무한 루프 배경

javascript
// 자동으로 반복되는 배경
speed = 50;
layerWidth = 1920;  // 레이어 너비

x = value[0] - (time * speed) % layerWidth;
[x, value[1]];

Tips

깊이 설정

  • 전경 (가까움): depth = 0.8 ~ 1.0
  • 중경: depth = 0.3 ~ 0.6
  • 배경 (멀리): depth = 0.1 ~ 0.2

Control 레이어

Null 레이어를 Control로 사용하면 하나의 레이어로 전체 패럴랙스를 제어할 수 있습니다.

슬라이더 컨트롤

각 레이어에 슬라이더를 추가하고 익스프레션에서 참조하면 깊이 값을 쉽게 조절할 수 있습니다.