vanilladocs
vanillapunch.com
API / effect/screeneffect

effect/screeneffect

화면 효과. (씬 후처리 사슬)

Screen effect. (scene post-processing chain)

ScreenEffectextends Object

짝Counterpart: vanilla-engine ScreenEffect

화면 효과. (씬 후처리 사슬)

  • 씬은 화면에 그대로 그리고, end() 에서 화면(또는 setRegion 으로 정한 영역)을 떠 와 켜진 효과를 차례로 건 뒤 같은 자리에 되돌려 놓는다.
  • 영역은 캔버스 픽셀 좌표(왼쪽 위 원점)이며 둥근 모서리 반지름을 주면 그 바깥은 원본을 유지한다.
  • 사용:
// 씬 load 에서
this.screenEffect = new ScreenEffect();
this.screenEffect.setEnabled(ScreenEffectType.vignette, true);
// preDraw 처음 / postDraw 끝에서
this.screenEffect.begin(graphic);  ...  this.screenEffect.end(graphic);
// tick 에서
this.screenEffect.tick(timeDelta);

Screen effect. (scene post-processing chain)

  • The scene draws to the screen as is, and end() captures the screen (or the region set with setRegion), applies the enabled effects in order, and puts it back in the same place.
  • The region is in canvas pixel coordinates (top-left origin), and if a rounded corner radius is given, the original is kept outside it.
  • Usage:
// in the scene's load
this.screenEffect = new ScreenEffect();
this.screenEffect.setEnabled(ScreenEffectType.vignette, true);
// at the start of preDraw / the end of postDraw
this.screenEffect.begin(graphic);  ...  this.screenEffect.end(graphic);
// in tick
this.screenEffect.tick(timeDelta);
예제Example씬 영역에 비네트와 색수차 걸기Apply a vignette and chromatic aberration to a scene region
import { Engine, EngineConfiguration, Scene, ScreenEffect, ScreenEffectType, Color, Colors, Rect } from "./build/vanilla.js";

class MainScene extends Scene {
	initialize(engine) {
		super.initialize(engine);
		const graphic = engine.getGraphic();
		this.screenEffect = new ScreenEffect();
		this.screenEffect.setRegion(40, 20, 560, 320, 24);
		this.screenEffect.setEnabled(ScreenEffectType.vignette, true);
		this.screenEffect.setColor(ScreenEffectType.vignette, new Color(0.1, 0, 0.2, 1));
		this.screenEffect.setEnabled(ScreenEffectType.chromatic, true);
		this.screenEffect.setStrength(ScreenEffectType.chromatic, 0.5);
	}

	tick(timeDelta) {
		super.tick(timeDelta);
		this.screenEffect.tick(timeDelta);
	}

	preDraw(graphic) {
		super.preDraw(graphic);
		this.screenEffect.begin(graphic);
		graphic.setFillColor(Colors.white);
		graphic.drawRect(Rect.create(220, 100, 200, 160));
	}

	postDraw(graphic) {
		super.postDraw(graphic);
		this.screenEffect.end(graphic);
	}
}

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
생성자constructorconstructor()#0.3.0 부터since 0.3.0소스source

생성.

  • 그래픽은 begin / end 에 받는다. (처음 그릴 때 그 WebGL2 컨텍스트를 받는다, 러스트 ScreenEffect::new() 와 같다)

Create.

  • The graphic is received in begin and end. (the WebGL2 context is taken the first time it draws, same as the Rust edition ScreenEffect::new())

짝Counterpart: vanilla-engine ScreenEffect.new

정적staticstatic getEffectOrder()#0.3.0 부터since 0.3.0소스source

적용 차례 반환. (정적)

Returns the apply order. (static)

반환Returnsstring[] 효과 이름의 적용 차례. (새 배열)Application order of effect names. (a new array)

짝Counterpart: vanilla-engine ScreenEffect.get_effect_order

메서드methodresetAll()#0.3.0 부터since 0.3.0소스source

전부 기본값으로. (끄고, 세기 1, 파라미터 / 색 기본, 모드 전환 때 이전 설정이 남지 않게)

Resets everything to defaults. (off, strength 1, default parameters / colors, so previous settings don't linger when switching modes)

짝Counterpart: vanilla-engine ScreenEffect.reset_all

메서드methodsetRegion(x, y, width, height, cornerRadius = 0)#0.3.0 부터since 0.3.0소스source

적용 영역 설정. (캔버스 픽셀, 왼쪽 위 원점, null 이면 화면 전체)

Sets the region to apply to. (canvas pixels, top-left origin, null means the whole screen)

xnumber
영역 왼쪽. (캔버스 픽셀)Region left. (canvas pixels)
ynumber
영역 위쪽. (캔버스 픽셀)Region top. (canvas pixels)
widthnumber
영역 가로. (캔버스 픽셀)Region width. (canvas pixels)
heightnumber
영역 세로. (캔버스 픽셀)Region height. (canvas pixels)
cornerRadiusnumber
둥근 모서리 반지름(픽셀). 0 이면 사각형.Rounded corner radius (pixels). 0 means a rectangle.

짝Counterpart: vanilla-engine ScreenEffect.set_region

메서드methodclearRegion()#0.3.0 부터since 0.3.0소스source

적용 영역 해제. (화면 전체)

Clears the region to apply to. (whole screen)

짝Counterpart: vanilla-engine ScreenEffect.clear_region

메서드methodgetRegion()#0.3.0 부터since 0.3.0소스source

적용 영역 반환.

Returns the region to apply to.

반환Returnsobject | null 적용 영역. ({ x, y, width, height, cornerRadius }, 화면 전체면 null)Applied region. ({ x, y, width, height, cornerRadius }, null for the whole screen)

짝Counterpart: vanilla-engine ScreenEffect.get_region

메서드methodtick(timeDelta)#0.3.0 부터since 0.3.0소스source

갱신. (애니메이션 효과의 시간)

Update. (time for animated effects)

timeDeltanumber
지난 시간. (초, 효과 시간에 더한다)Elapsed time. (seconds, added to the effect time)

짝Counterpart: vanilla-engine ScreenEffect.tick

메서드methodbegin(graphic)#0.3.0 부터since 0.3.0소스source

시작. (씬 preDraw 첫머리, 씬은 화면에 그대로 그린다. 켜진 효과가 있을 때만 end 가 일한다)

Begin. (at the start of the scene's preDraw, the scene draws to the screen as is. end does work only when an effect is enabled)

graphicGraphic
씬의 그래픽.Graphic of the scene.

짝Counterpart: vanilla-engine ScreenEffect.begin

메서드methodend(graphic)#0.3.0 부터since 0.3.0소스source

효과 적용. (씬 postDraw 끝, 화면의 영역을 떠 와 효과를 걸고 같은 자리에 되돌려 놓는다)

Applies the effects. (at the end of the scene's postDraw, captures the screen region, applies the effects and puts it back in the same place)

graphicGraphic
씬의 그래픽.Graphic of the scene.

짝Counterpart: vanilla-engine ScreenEffect.end

메서드methodhasActiveEffect()#0.3.0 부터since 0.3.0소스source

켜진 효과 여부. (세기 0 은 꺼진 것으로 본다)

Whether any effect is enabled. (strength 0 counts as off)

반환Returnsboolean 켜졌고 세기가 0 보다 큰 효과가 있으면 참.True if an effect is enabled with a strength above 0.

짝Counterpart: vanilla-engine ScreenEffect.has_active_effect

메서드methodensureTargets(width, height)#0.3.0 부터since 0.3.0소스source

렌더 대상 준비. (크기가 바뀌면 다시 만든다)

Prepares the render targets. (recreated when the size changes)

widthnumber
가로. (드로잉 버퍼 픽셀)Width. (drawing buffer pixels)
heightnumber
세로. (드로잉 버퍼 픽셀)Height. (drawing buffer pixels)
메서드methodresolvePass(passName)#0.3.0 부터since 0.3.0소스source

패스 반환. (없으면 컴파일. 실패도 담아 두고 한 번만 알린다, 실패한 패스의 단계는 건너뛴다)

Returns a pass. (compiles it if missing. A failure is also cached and reported only once, and steps with a failed pass are skipped)

passNamestring
패스 이름. (효과 이름이나 copy, bloomBright 같은 내부 단계 이름)Pass name. (an effect name or an internal step name such as copy or bloomBright)

반환ReturnsFullscreenPass | null 패스. (셰이더 짓기에 실패했으면 null)Pass. (null if building the shader failed)

메서드methodsetEnabled(effectType, isEnabled)#0.3.0 부터since 0.3.0소스source

효과 켜기 / 끄기.

Turns an effect on / off.

effectTypestring
ScreenEffectType 값. (모르는 값이면 무시한다)ScreenEffectType value. (ignored if unknown)
isEnabledboolean
켜면 참.True to enable.

짝Counterpart: vanilla-engine ScreenEffect.set_enabled

메서드methodisEnabled(effectType)#0.3.0 부터since 0.3.0소스source

효과 켜짐 여부 반환.

Returns whether an effect is on.

effectTypestring
ScreenEffectType 값.ScreenEffectType value.

반환Returnsboolean 켜졌으면 참. (모르는 값이면 거짓)True if enabled. (false if unknown)

짝Counterpart: vanilla-engine ScreenEffect.is_enabled

메서드methodsetStrength(effectType, strength)#0.3.0 부터since 0.3.0소스source

세기 설정. (0 이면 꺼진 것과 같다)

Sets the strength. (0 is the same as off)

effectTypestring
ScreenEffectType 값. (모르는 값이면 무시한다)ScreenEffectType value. (ignored if unknown)
strengthnumber
세기. (기본 1, 0 이하이면 꺼진 것으로 본다)Strength. (default 1, treated as off if 0 or less)

짝Counterpart: vanilla-engine ScreenEffect.set_strength

메서드methodgetStrength(effectType)#0.3.0 부터since 0.3.0소스source

세기 반환.

Returns the strength.

effectTypestring
ScreenEffectType 값.ScreenEffectType value.

반환Returnsnumber 세기. (모르는 값이면 0)Strength. (0 if unknown)

짝Counterpart: vanilla-engine ScreenEffect.get_strength

메서드methodsetParameters(effectType, x, y = 0, z = 0, w = 0)#0.3.0 부터since 0.3.0소스source

파라미터 설정. (효과마다 뜻이 다르다, ScreenEffectType 주석 참고)

Sets the parameters. (meaning differs per effect, see the ScreenEffectType comments)

effectTypestring
ScreenEffectType 값. (모르는 값이면 무시한다)ScreenEffectType value. (ignored if unknown)
xnumber
첫째 파라미터.First parameter.
ynumber
둘째 파라미터. (기본 0)Second parameter. (default 0)
znumber
셋째 파라미터. (기본 0)Third parameter. (default 0)
wnumber
넷째 파라미터. (기본 0)Fourth parameter. (default 0)

짝Counterpart: vanilla-engine ScreenEffect.set_parameters

메서드methodsetParameter(effectType, parameterName, value)#0.3.0 부터since 0.3.0소스source

파라미터 하나 설정. (이름은 SCREEN_EFFECT_PARAMETER_NAMES)

Sets a single parameter. (names in SCREEN_EFFECT_PARAMETER_NAMES)

effectTypestring
ScreenEffectType 값. (모르는 값이면 무시한다)ScreenEffectType value. (ignored if unknown)
parameterNamestring
파라미터 이름. (SCREEN_EFFECT_PARAMETER_NAMES 의 것, 없는 이름이면 무시한다)Parameter name. (one of SCREEN_EFFECT_PARAMETER_NAMES, ignored if the name does not exist)
valuenumber
값.Value.

짝Counterpart: vanilla-engine ScreenEffect.set_parameter

메서드methodgetParameters(effectType)#0.3.0 부터since 0.3.0소스source

파라미터 반환.

Returns the parameters.

effectTypestring
ScreenEffectType 값.ScreenEffectType value.

반환Returnsnumber[] 파라미터. ([x, y, z, w], 복사하지 않은 배열, 모르는 값이면 0 넷)Parameters. ([x, y, z, w], the array itself, not a copy, four zeros if unknown)

짝Counterpart: vanilla-engine ScreenEffect.get_parameters

메서드methodsetColor(effectType, color)#0.3.0 부터since 0.3.0소스source

색 설정.

Sets the color.

effectTypestring
ScreenEffectType 값. (모르는 값이면 무시한다)ScreenEffectType value. (ignored if unknown)
colorColor | string
효과 색. (복사해 둔다, null 이면 무시한다)Effect color. (kept as a copy, ignored if null)

짝Counterpart: vanilla-engine ScreenEffect.set_color

메서드methodgetColor(effectType)#0.3.0 부터since 0.3.0소스source

색 반환.

Returns the color.

effectTypestring
ScreenEffectType 값.ScreenEffectType value.

반환ReturnsColor 효과 색. (모르는 값이면 흰색)Effect color. (white if unknown)

짝Counterpart: vanilla-engine ScreenEffect.get_color

메서드methoddisableAll()#0.3.0 부터since 0.3.0소스source

전부 끄기.

Turns everything off.

짝Counterpart: vanilla-engine ScreenEffect.disable_all

메서드methodsetTimelineProperty(propertyName, value)#0.3.0 부터since 0.3.0소스source

타임라인 속성 적용. ("vignette" = 세기(0 이면 끔), "shockwave.radius" = 파라미터, "fade.color" = 색)

Applies a timeline property. ("vignette" = strength (0 turns it off), "shockwave.radius" = parameter, "fade.color" = color)

propertyNamestring
속성 이름. ("효과" 는 세기, "효과.color" 는 색, "효과.enabled" 는 켜짐, "효과.파라미터 이름" 은 파라미터, 모르는 효과면 무시한다)Property name. ("effect" is the strength, "effect.color" the color, "effect.enabled" the enabled state, "effect.parameter name" a parameter, ignored if the effect is unknown)
value*
값. (세기와 파라미터는 숫자로 바꾸고, 색은 HEX 글만 받는다)Value. (strength and parameters are converted to numbers, colors accept only HEX strings)

짝Counterpart: vanilla-engine ScreenEffect.set_timeline_property

예제Example타임라인 속성 이름으로 충격파와 페이드 바꾸기Change a shockwave and a fade by timeline property names
import { Engine, EngineConfiguration, ScreenEffect, ScreenEffectType } from "./build/vanilla.js";

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const graphic = engine.getGraphic();
const screenEffect = new ScreenEffect();
screenEffect.setTimelineProperty("shockwave", 1);
screenEffect.setTimelineProperty("shockwave.radius", 0.4);
screenEffect.setTimelineProperty("fade.color", "#ff8800");
screenEffect.setParameter(ScreenEffectType.shockwave, "width", 0.2);
console.log(screenEffect.isEnabled(ScreenEffectType.shockwave), screenEffect.getParameters(ScreenEffectType.shockwave));
메서드methodgetTime()#0.3.0 부터since 0.3.0소스source

시간 반환.

Returns the time.

반환Returnsnumber 효과 시간. (초)Effect time. (seconds)

짝Counterpart: vanilla-engine ScreenEffect.get_time

메서드methodgetSceneTexture()#0.3.0 부터since 0.3.0소스source

씬 텍스처 반환. (end 이후, 마지막 프레임에 떠 온 영역 원본)

Returns the scene texture. (after end, the original of the region captured in the last frame)

반환ReturnsWebGLTexture | null 떠 온 영역 텍스처. (아직 없으면 null)Captured region texture. (null if none yet)

짝Counterpart: vanilla-engine ScreenEffect.get_scene_texture

메서드methoddestroy()#0.3.0 부터since 0.3.0소스source

파괴. (WebGL 자원 해제: 렌더 대상과 패스 프로그램)

Destroy. (frees WebGL resources: render targets and pass programs)

짝Counterpart: vanilla-engine ScreenEffect.destroy

상수Constants

상수constantSCREEN_EFFECT_PARAMETER_NAMES#0.3.0 부터since 0.3.0소스source

효과별 파라미터 이름. (타임라인 속성 "효과.이름" 으로 접근)

Parameter names per effect. (accessed as the timeline property "effect.name")

짝Counterpart: vanilla-engine SCREEN_EFFECT_PARAMETER_NAMES

ScreenEffectTypeenum

짝Counterpart: vanilla-engine ScreenEffectType

화면 효과 종류.

Screen effect types.

이름Name값Value설명Description
lensDistortionlensDistortion--- 형태 왜곡 ------ Shape distortion ---
bulgebulge볼록 / 오목. (parameters = [중심 x, 중심 y, 세기, 반지름])Bulge / pinch. (parameters = [center x, center y, strength, radius])
swirlswirl소용돌이. (parameters = [중심 x, 중심 y, 회전 수, 반지름])Swirl. (parameters = [center x, center y, turn count, radius])
kaleidoscopekaleidoscope만화경. (parameters = [조각 수])Kaleidoscope. (parameters = [segment count])
mirrormirror대칭. (parameters = [0 가로 / 1 세로])Symmetry. (parameters = [0 horizontal / 1 vertical])
rippleripple물 파문. (parameters = [중심 x, 중심 y, 빈도, 속도])Water ripple. (parameters = [center x, center y, frequency, speed])
heatHazeheatHaze아지랑이. (parameters = [노이즈 배율, 속도])Heat haze. (parameters = [noise scale, speed])
jitterjitter화면 흔들림. (parameters = [진폭 픽셀, 초당 변화])Screen shake. (parameters = [amplitude pixels, changes per second])
doubleVisiondoubleVision겹쳐 보임. (parameters = [간격, 흔들리는 속도])Double vision. (parameters = [spacing, sway speed])
pixelatepixelate모자이크. (strength 0 → 1, parameters = [가장 큰 블록 픽셀])Mosaic. (strength 0 → 1, parameters = [largest block pixels])
shockwaveshockwave충격파 링 왜곡. (parameters = [중심 x, 중심 y, 반지름 0 ~ 1.5, 폭], color = 링 빛)Shockwave ring distortion. (parameters = [center x, center y, radius 0 ~ 1.5, width], color = ring light)
wavewave화면 물결. (parameters = [빈도, 속도])Screen wave. (parameters = [frequency, speed])
motionBlurmotionBlur--- 흐림 ------ Blur ---
zoomBlurzoomBlur중심으로 뻗는 방사 블러. (parameters = [중심 x, 중심 y, 길이])Radial blur streaking toward the center. (parameters = [center x, center y, length])
blurblur가우시안 블러. (parameters = [반지름 픽셀])Gaussian blur. (parameters = [radius pixels])
gaussianBlurgaussianBlur표준편차 가우시안 블러. (parameters = [표준편차 픽셀], CSS filter: blur() 와 같은 뜻, 분리형 선형 샘플링, 3 시그마까지)Standard-deviation Gaussian blur. (parameters = [standard deviation in pixels], same meaning as CSS filter: blur(), separable linear sampling, up to 3 sigma)
tiltShifttiltShift틸트 시프트. (parameters = [초점 y, 초점 폭, 반지름 픽셀])Tilt-shift. (parameters = [focus y, focus width, radius pixels])
godRaysgodRays빛줄기. (parameters = [중심 x, 중심 y, 문턱, 감쇠], color = 빛 색)Light shafts. (parameters = [center x, center y, threshold, decay], color = light color)
bloombloom밝은 곳 번짐. (parameters = [문턱, 세기 배율, 반지름 픽셀])Bloom of bright areas. (parameters = [threshold, strength scale, radius pixels])
anamorphicanamorphic가로 렌즈 플레어. (parameters = [문턱, 세기 배율, 폭 픽셀], color = 플레어 색)Horizontal lens flare. (parameters = [threshold, strength scale, width pixels], color = flare color)
glitchglitch--- 글리치 ------ Glitch ---
vhsvhsVHS 테이프. (흔들림 + 색 번짐 + 노이즈 줄, parameters = [흔들림, 노이즈])VHS tape. (shake + color bleeding + noise lines, parameters = [shake, noise])
chromaticchromatic색수차. (parameters = [배율])Chromatic aberration. (parameters = [scale])
whiteBalancewhiteBalance--- 색 ------ Color ---
liftGammaGainliftGammaGain리프트 / 감마 / 게인. (parameters = [리프트, 감마, 게인])Lift / gamma / gain. (parameters = [lift, gamma, gain])
colorGradecolorGrade대비 / 채도 / 밝기 + 틴트. (parameters = [대비, 채도, 밝기], color = 틴트)Contrast / saturation / brightness + tint. (parameters = [contrast, saturation, brightness], color = tint)
hueShifthueShift색상 회전. (parameters = [회전 수, strength 와 곱])Hue rotation. (parameters = [turn count, multiplied by strength])
splitToningsplitToning스플릿 토닝. (parameters.xyz = 그림자 색, color = 하이라이트 색, w = 균형)Split toning. (parameters.xyz = shadow color, color = highlight color, w = balance)
tonemaptonemapACES 톤매핑. (parameters = [노출])ACES tone mapping. (parameters = [exposure])
gradientMapgradientMap밝기를 두 색 사이로 매핑. (parameters.xyz = 어두운 색, color = 밝은 색)Maps brightness between two colors. (parameters.xyz = dark color, color = bright color)
sepiasepia세피아.Sepia.
grayscalegrayscale무채색.Grayscale.
posterizeposterize포스터화. (parameters = [단계 수])Posterize. (parameters = [step count])
ditherdither오더드 디더링. (parameters = [단계 수, 픽셀 크기])Ordered dithering. (parameters = [step count, pixel size])
halftonehalftone하프톤 점. (parameters = [격자 픽셀])Halftone dots. (parameters = [grid pixels])
sharpensharpen샤픈.Sharpen.
edgeDetectedgeDetect윤곽 검출. (color = 선 색)Edge detection. (color = line color)
oldFilmoldFilm낡은 필름. (세피아 + 그레인 + 스크래치 + 깜빡임)Old film. (sepia + grain + scratches + flicker)
nightVisionnightVision야시경. (color = 틴트)Night vision. (color = tint)
invertinvert색 반전.Color inversion.
scanlinescanline--- 무늬 / 마스크 ------ Pattern / mask ---
graingrain필름 그레인.Film grain.
rainrain빗줄기. (parameters = [줄 수, 밀도, 속도], color = 빗줄기 색)Rain streaks. (parameters = [line count, density, speed], color = streak color)
fogfog세로 안개. (parameters = [시작 y, 끝 y], color = 안개 색)Vertical fog. (parameters = [start y, end y], color = fog color)
vignettevignette비네트. (parameters = [시작 거리, 끝 거리], color = 가장자리 색)Vignette. (parameters = [start distance, end distance], color = edge color)
spotlightspotlight스포트라이트 바깥 어둡힘. (parameters = [중심 x, 중심 y, 반지름, 부드러움], color = 바깥 색)Darkening outside a spotlight. (parameters = [center x, center y, radius, softness], color = outside color)
speedLinesspeedLines집중선. (parameters = [중심 x, 중심 y, 밀도, 속도], color = 선 색)Focus lines. (parameters = [center x, center y, density, speed], color = line color)
letterboxletterbox위아래 / 좌우 검은 띠. (parameters = [세로 띠 비율, 가로 띠 비율], color = 띠 색)Black bars at top and bottom / left and right. (parameters = [vertical bar ratio, horizontal bar ratio], color = bar color)
pixelDissolvepixelDissolve--- 전환 (strength 0 → 1 로 color 에 덮인다) ------ Transitions (covered by color as strength goes 0 → 1) ---
wipewipe방향 와이프. (parameters = [방향 x, 방향 y, 부드러움])Directional wipe. (parameters = [direction x, direction y, softness])
irisWipeirisWipe원형 아이리스. (parameters = [중심 x, 중심 y, 부드러움])Circular iris. (parameters = [center x, center y, softness])
diamondWipediamondWipe마름모 와이프. (parameters = [부드러움])Diamond wipe. (parameters = [softness])
clockWipeclockWipe시계 와이프. (parameters = [부드러움])Clock wipe. (parameters = [softness])
blindsblinds블라인드. (parameters = [줄 수, 부드러움])Blinds. (parameters = [line count, softness])
checkerWipecheckerWipe체커 보드. (parameters = [칸 수])Checkerboard. (parameters = [cell count])
noiseFadenoiseFade노이즈 페이드. (parameters = [노이즈 배율, 부드러움])Noise fade. (parameters = [noise scale, softness])
burnburn불에 타듯. (parameters = [노이즈 배율, 띠 폭], color = 덮을 색, 띠는 주황)As if burning. (parameters = [noise scale, band width], color = cover color, the band is orange)
tvOfftvOff브라운관 끄기. (세로로 눌리며 밝은 선으로)CRT turn-off. (squashes vertically into a bright line)
fadefade단색으로 페이드. (color = 목표 색)Fade to a solid color. (color = target color)