graphics3d/toon/toonvfx
툰 3D GPU 효과의 바탕. (vanilla.js graphics3d/toon/toonvfx.js 의 ToonVfx)
- 텍스처: 그림 파일 없이 처음 그릴 때 코드로 짓는 아틀라스 한 장. 왼쪽 반은 연기 플립북 16 칸, 오른쪽 반은 ToonVfxSlot 칸과 색 램프 여덟 줄. 램프 색은 게임이 정한다. (set_ramps, 줄마다 흰 심에서 어둠으로 가는 색들, 효과의 ramp 는 줄 번호, -1 이면 램프 없이 color 만)
- 파티클: 인스턴스로 그리는 GPU 파티클. 낼 때 한 번 버퍼에 쓰고 자리, 크기, 색은 정점 셰이더가 나이로 셈한다. (끌림, 중력, 바닥에서 멈춤, 속도 쪽으로 늘인 줄기, 색 램프) 상한(set_particle_capacity)을 넘으면 가장 오래 전에 낸 것부터 덮고, set_count_ratio 로 내는 수에 몫을 곱한다. (폰과 가벼운 길)
- 효과 메쉬: 불덩이(add_fireball), 충격파 띠와 바닥 빛(add_shockwave), 바닥 자국(add_decal, queue_decal), 연기 기둥(add_plume), 회전체 빔(queue_beam), 카메라 쪽으로 편 리본(queue_ribbon)과 그것을 감아 내린 번개(queue_lightning), 사는 동안 다시 꺾이는 번개(add_lightning), 그 자리의 빛 점(queue_glint).
- 테: 빛 파티클의 rim, 리본의 glow 와 rim, 불덩이와 충격파의 rim 은 가장자리를 테 색(set_rim_color)으로 덮어 밝은 바탕에서도 보이게 한다. (기본은 더하는 빛만)
- 밝기 배: set_look_gain(꼴, 배) 로 파티클과 빛 점의 꼴마다 밝기를 곱한다. (기본 1, HDR 판에서 불꽃 줄기, 빛살, 불씨를 선형 몇 배로 할 때)
- 나이와 열쇠: emit_particles, add_fireball, add_shockwave, add_decal, add_plume, add_lightning, add_flash 는 options 의 age(이미 지난 초, 음수면 그만큼 늦게)와 key(사건 열쇠, 이미 낸 열쇠면 다시 내지 않음, clear 가 잊음)를 받는다. 장면이 매 프레임 상태에서 사건을 다시 내도 한 번만, 늦게 보인 효과는 그 나이부터 튼다. 흔들림(add_shake)은 Shaker 의 지수 감쇠(초당 9)라 늦게 보인 사건은 세기 x exp(-9 x 나이) 로 넘기면 같다.
- 발밑 그늘: queue_blob_shadow 는 그 프레임의 둥근 그늘 자국(ToonVfxDecalMode::Shade)이다.
- 화면: 섬광(add_flash)은 draw 끝에 지금 뷰포트(가위가 걸려 있으면 그 안)를 그 색으로 덮고 걷힌다. 카메라 흔들림(add_shake)은 엔진 Shaker 로 셈하고, read_shake 가 준 오프셋을 게임이 카메라의 오른쪽과 위쪽으로 더한다.
- 어느 사건에 어느 효과를 어떤 값으로 낼지(처방)는 게임 몫이다. 엔진은 매개변수만 받는다.
- 바닥: set_floor_height_reader 로 게임이 바닥 높이를 알려 주면 자국, 충격파, 연기 기둥은 그 높이에, is_grounded 파티클은 그 높이에서 멈춘다. (없으면 0)
- 시계: update(초) 가 이 바탕의 시계를 나아가게 한다. queue 로 넘긴 것은 그 프레임에 한 번 그리고 비운다.
- 그리기: draw(gl, 보기, 투영) 를 툰 모형을 그린 뒤 부른다. 깊이 시험은 켜고 깊이는 쓰지 않으며 미리 곱한 알파로 섞는다. 앞의 상태(프로그램과 버텍스 어레이 포함)를 적어 두었다 돌린다.
- 원본과 다른 점: 효과마다의 options 객체 대신 기본값을 가진 구조체(ToonParticleOptions 등)를 받는다. 범위가 되는 값은 ToonVfxRange 다. 원본에서 주지 않아도 되는 값(undefined)은 Option 이다. add_lightning 의 life, age 는 ToonLightningOptions 에 함께 든다. 사건 열쇠는 원본이 수나 글을 받지만 러스트 판은 u64 다. (글 열쇠는 게임이 수로 바꿔 넘긴다)
Base of toon 3D GPU effects. (ToonVfx of vanilla.js graphics3d/toon/toonvfx.js)
- Texture: a single atlas built in code on the first draw, without image files. The left half is a 16-cell smoke flipbook, the right half is ToonVfxSlot cells and eight rows of color ramps. Ramp colors are decided by the game. (set_ramps, each row is colors going from a white core to dark, an effect's ramp is the row number, -1 means color only without a ramp)
- Particles: GPU particles drawn with instancing. Written to the buffer once when emitted, and position, size and color are computed by the vertex shader from age. (Drag, gravity, stopping on the floor, streaks stretched along velocity, color ramps) When the cap (set_particle_capacity) is exceeded, the oldest emitted are overwritten first, and set_count_ratio multiplies the emitted count by a fraction. (Phones and the lite path)
- Effect meshes: fireballs (add_fireball), shockwave rings and floor glow (add_shockwave), floor decals (add_decal, queue_decal), smoke plumes (add_plume), solid-of-revolution beams (queue_beam), ribbons spread toward the camera (queue_ribbon) and lightning made by winding them down (queue_lightning), lightning that re-bends during its lifetime (add_lightning), and point glints at a spot (queue_glint).
- Rim: the rim of glow particles, the glow and rim of ribbons, and the rim of fireballs and shockwaves cover the edges with the rim color (set_rim_color) so they are visible on bright backgrounds too. (Default is additive light only)
- Brightness gain: set_look_gain(look, gain) multiplies brightness per look of particles and glints. (Default 1, for making flame streaks, light rays and embers several times brighter in linear in the HDR version)
- Age and key: emit_particles, add_fireball, add_shockwave, add_decal, add_plume, add_lightning, add_flash take the options age (seconds already elapsed, negative delays by that much) and key (event key, not emitted again if already emitted, forgotten by clear). Even if the scene re-emits events from state every frame they appear only once, and effects shown late start from that age. Shake (add_shake) uses Shaker's exponential decay (9 per second), so passing strength x exp(-9 x age) for a late-shown event gives the same result.
- Foot shadow: queue_blob_shadow is a round shade decal for that frame (ToonVfxDecalMode::Shade).
- Screen: the flash (add_flash) covers the current viewport (inside the scissor if one is set) with its color at the end of draw and then fades. Camera shake (add_shake) is computed with the engine Shaker, and the game adds the offset given by read_shake to the camera's right and up.
- Which effect to emit for which event with what values (the recipe) is up to the game. The engine only takes parameters.
- Floor: if the game reports the floor height with set_floor_height_reader, decals, shockwaves and smoke plumes are placed at that height, and is_grounded particles stop at that height. (0 if none)
- Clock: update(seconds) advances this base's clock. Items passed with queue are drawn once in that frame and then cleared.
- Drawing: call draw(gl, view, projection) after drawing the toon models. Depth test on, depth write off, blends with premultiplied alpha. Records the previous state (including program and vertex array) and restores it.
- Differences from the original: instead of an options object per effect, takes structs with default values (ToonParticleOptions and so on). Values that can be ranges are ToonVfxRange. Values that may be omitted in the original (undefined) are Option. The life and age of add_lightning are in ToonLightningOptions too. The original takes a number or string as the event key, but the Rust version takes u64. (The game converts string keys to numbers)
ToonVfxRangestruct traits Clone, Copy, Debug, PartialEq, From<f64>
값의 범위. (최소와 최대 사이 무작위, 같으면 그 값)
Value range. (random between minimum and maximum, that value when they are equal)
use vanilla::{ToonParticleOptions, ToonVfxRange};
let speed = ToonVfxRange::new(2.0, 5.0);
let size = ToonVfxRange::from(0.1);
assert_eq!(size.minimum, size.maximum);
let options = ToonParticleOptions { count: 40, speed, size, life: ToonVfxRange::new(0.4, 0.9), ..ToonParticleOptions::default() };
assert_eq!(options.speed.maximum, 5.0);생성.
Constructor.
- minimumf64
- 최소.Minimum.
- maximumf64
- 최대.Maximum.
반환ReturnsToonVfxRange 새 범위.New range.
ToonParticleOptionsstruct traits Clone, Copy, Debug, Default
파티클 내기의 값.
Particle emission options.
use vanilla::{ToonParticleOptions, ToonVfx, ToonVfxLook, ToonVfxRange, ToonVfxShape};
fn emit_sparks(vfx: &mut ToonVfx) {
let spark_options = ToonParticleOptions {
count: 30,
position: [0.0, 1.0, 0.0],
shape: ToonVfxShape::Cone,
direction: [0.0, 1.0, 0.0],
spread: 0.4,
speed: ToonVfxRange::new(3.0, 6.0),
gravity: 9.0,
drag: 1.5,
size: ToonVfxRange::new(0.04, 0.08),
size_end: ToonVfxRange::from(0.3),
life: ToonVfxRange::new(0.5, 1.0),
look: ToonVfxLook::Streak,
stretch: 0.04,
color: [1.0, 0.7, 0.3],
is_grounded: true,
age: 0.1,
key: Some(12),
..ToonParticleOptions::default()
};
vfx.emit_particles(&spark_options);
vfx.emit_particles(&spark_options);
}낼 수. (set_count_ratio 의 몫을 곱한다)
Emit count. (multiplied by the set_count_ratio factor)
반환Returnsu32
아래로 가는 쪽을 위로 뒤집을지.
Whether to flip downward directions upward.
반환Returnsbool
속도를 무시하고 나이가 다할 때 낸 자리로 빨려 들지.
Whether to ignore velocity and be pulled into the emission point as the age runs out.
반환Returnsbool
처음 빠르기. (내는 쪽으로)
Initial speed. (in the emit direction)
반환ReturnsToonVfxRange
끌림. (빠르기가 exp(-drag x 나이) 로 준다)
Drag. (speed decreases by exp(-drag x age))
반환Returnsf64
끝 크기. (시작 크기에 곱함)
End size. (multiplied by the start size)
반환ReturnsToonVfxRange
크기가 처음에서 끝으로 가는 굽기. (나아감의 거듭제곱, 1 이면 곧게)
Curve of the size from start to end. (power of the progress, 1 for linear)
반환Returnsf64
색. (0 ~ 1 의 [r, g, b], 램프가 있으면 램프 색에 곱함)
Color. ([r, g, b] in 0 ~ 1, multiplied by the ramp color if there is a ramp)
반환Returns[f64; 3]
Streak 꼴에서 화면에 비친 속도에 곱하는 늘임.
Stretch multiplied by the screen-projected velocity in the Streak look.
반환Returnsf64
초당 도는 각. (라디안, Streak 꼴은 속도 쪽을 따르므로 돌지 않음)
Rotation angle per second. (radians, the Streak look follows the velocity direction so it does not rotate)
반환ReturnsToonVfxRange
멈출 바닥 높이. (None 이면 is_grounded 를 본다)
Floor height to stop at. (when None, is_grounded is checked)
반환ReturnsOption<f64>
낸 자리의 바닥 높이에서 멈출지.
Whether to stop at the floor height of the emission point.
반환Returnsbool
밝기 배. (꼴마다의 set_look_gain 배도 곱함)
Brightness multiplier. (the per-look set_look_gain multiplier is also applied)
반환Returnsf64
나타나는 몫. (나이의 이만큼 동안 엷음에서 짙어짐)
Fade-in fraction. (goes from faint to solid over this fraction of the age)
반환Returnsf64
빛의 꼴의 테. (0 이면 더하는 빛만, 1 이면 테 색으로 덮음, 음수면 엷게 덮는 빛무리)
Rim of the light look. (0 is additive light only, 1 covers with the rim color, negative is a faintly covering halo)
반환Returnsf64
이미 지난 초. (음수면 그만큼 늦게)
Seconds already elapsed. (if negative, delayed by that much)
반환Returnsf64
사건 열쇠. (이미 낸 열쇠면 내지 않음)
Event key. (not emitted if the key was already emitted)
반환ReturnsOption<u64>
ToonFireballOptionsstruct traits Clone, Copy, Debug, Default
불덩이의 값.
Fireball options.
use vanilla::{ToonFireballOptions, ToonVfx};
fn add_barrel_explosion(vfx: &mut ToonVfx) {
vfx.set_ramps(&[vec!["#ffffff", "#ffe080", "#ff8020", "#801808", "#200804"]]);
vfx.add_fireball(&ToonFireballOptions { position: [0.0, 1.0, 0.0], radius: 1.2, life: 1.5, ramp: 0, rise: 1.0, grow_seconds: 0.25, boil: 0.4, smoke_color: [0.2, 0.18, 0.16], key: Some(3), ..ToonFireballOptions::default() });
}다 부푼 반지름. (끝까지 1.25 배로 더 커진다)
Fully expanded radius. (grows a further 1.25 times by the end)
반환Returnsf64
식어 덮는 연기 색.
Smoke color that covers it as it cools.
반환Returns[f64; 3]
부푸는 초. (반지름의 0.25 배에서 1 배로)
Expansion time in seconds. (from 0.25 times the radius to 1 times)
반환Returnsf64
덮는 꼴의 몫. (0 이면 더하는 빛만, 1 이면 몸을 덮고 가장자리를 테 색으로)
Cover look fraction. (0 is additive light only, 1 covers the body and paints the edge with the rim color)
반환Returnsf64
이미 지난 초. (음수면 그만큼 늦게)
Seconds already elapsed. (if negative, delayed by that much)
반환Returnsf64
사건 열쇠. (이미 낸 열쇠면 내지 않음)
Event key. (not emitted if the key was already emitted)
반환ReturnsOption<u64>
ToonShockwaveOptionsstruct traits Clone, Copy, Debug, Default
충격파 띠의 값.
Shockwave ring options.
use vanilla::{ToonShockwaveOptions, ToonVfx};
fn add_shockwave(vfx: &mut ToonVfx) {
vfx.add_shockwave(&ToonShockwaveOptions { x: 0.0, z: 0.0, start_radius: 0.2, end_radius: 4.0, width: 0.8, life: 0.7, ramp: 0, color: [1.0, 0.9, 0.7], lift: 0.4, delay: 0.05, rim: 0.5, ..ToonShockwaveOptions::default() });
}퍼지는 처음과 끝 반지름. (빠르게 퍼지다 천천히)
Start and end radius of the spread. (spreads fast, then slowly)
반환Returnsf64
띠 너비. (나이만큼 0.55 배까지 가늘어지고 반지름을 넘지 않음)
Band width. (thins to 0.55 times with age and does not exceed the radius)
반환Returnsf64
덮는 꼴의 몫. (0 이면 더하는 빛만, 1 이면 띠의 몸을 테 색으로 덮고 심은 색)
Cover look fraction. (0 is additive light only, 1 covers the ring body with the rim color and the core with the color)
반환Returnsf64
이미 지난 초. (음수면 그만큼 늦게)
Seconds already elapsed. (if negative, delayed by that much)
반환Returnsf64
사건 열쇠. (이미 낸 열쇠면 내지 않음)
Event key. (not emitted if the key was already emitted)
반환ReturnsOption<u64>
ToonDecalOptionsstruct traits Clone, Copy, Debug, Default
바닥 자국의 값. (queue_decal 은 나이 대신 heat 를 쓴다)
Floor decal options. (queue_decal uses heat instead of age)
use vanilla::{ToonDecalOptions, ToonVfx, ToonVfxDecalMode, ToonVfxSlot};
fn add_decals(vfx: &mut ToonVfx) {
vfx.add_decal(&ToonDecalOptions { x: 0.0, z: 0.0, radius: 1.5, start_radius: Some(0.4), grow_seconds: 0.3, life: 10.0, heat_seconds: 2.0, slot: ToonVfxSlot::Scorch, mode: ToonVfxDecalMode::Scorch, ramp: 0, ..ToonDecalOptions::default() });
vfx.add_decal(&ToonDecalOptions { x: 3.0, z: 0.0, radius: 0.8, life: 6.0, mode: ToonVfxDecalMode::Stain, tint: [0.2, 0.45, 0.1], alpha: 0.7, flicker: 0.25, ..ToonDecalOptions::default() });
}반지름. (start_radius 에서 grow_seconds 동안 퍼져 닿는 반지름)
Radius. (the radius reached by spreading from start_radius over grow_seconds)
반환Returnsf64
퍼지기 시작하는 반지름. (None 이면 radius)
Radius it starts spreading from. (radius when None)
반환ReturnsOption<f64>
퍼지는 초. (0 이면 처음부터 radius)
Spread time in seconds. (0 for radius from the start)
반환Returnsf64
사는 초. (끝 1 초에 엷어짐)
Lifetime in seconds. (fades over the last 1 second)
반환Returnsf64
열기가 식는 초. (0 이면 열기 없음)
Time in seconds for the heat to cool. (0 for no heat)
반환Returnsf64
열기와 빛, 테의 램프 줄. (Scorch, Glow, Ring 꼴이 읽는다)
Ramp row for heat, glow and ring. (Read by the Scorch, Glow and Ring modes)
반환Returnsi32
색. (빛과 테는 램프 색에 곱하고, Stain, Sheen 은 이 색으로 덮는다)
Color. (multiplied by the ramp color for glow and ring, Stain and Sheen are covered with this color)
반환Returns[f64; 3]
돎. (None 이면 add_decal 은 무작위, queue_decal 은 0)
Rotation. (when None, random for add_decal and 0 for queue_decal)
반환ReturnsOption<f64>
Ring 꼴의 (테 반지름, 테 너비, 잡음 잘기, 흐르는 빠르기). (반지름 몫)
(ring radius, ring width, noise fineness, flow speed) of the Ring mode. (fractions of the radius)
반환Returns[f64; 4]
잡음 씨앗. (None 이면 add_decal 은 무작위, queue_decal 은 0)
Noise seed. (when None, random for add_decal and 0 for queue_decal)
반환ReturnsOption<f64>
깜빡이는 반주기 초. (0 이면 없음, 반주기마다 걸러 엷게)
Flicker half period in seconds. (none at 0, fades every other half period)
반환Returnsf64
이미 지난 초. (add_decal 만 읽음, 음수면 그만큼 늦게)
Seconds already elapsed. (read only by add_decal, if negative, delayed by that much)
반환Returnsf64
사건 열쇠. (add_decal 만 읽음, 이미 낸 열쇠면 내지 않음)
Event key. (read only by add_decal, not emitted if the key was already emitted)
반환ReturnsOption<u64>
ToonBlobShadowOptionsstruct traits Clone, Copy, Debug, Default
발밑 그늘의 값. (가운데 alpha 에서 바깥으로 둥글게 엷어지는 그늘)
Foot shadow options. (shade fading roundly outward from alpha at the center)
use vanilla::{Matrix4, ToonBlobShadowOptions, ToonVfx, Vector3};
fn draw_blob_shadows(gl: &vanilla::GlContext, vfx: &mut ToonVfx) {
let view_matrix = Matrix4::create_look_at(Vector3::create(0.0, 4.0, 6.0), Vector3::create(0.0, 0.0, 0.0), Vector3::create(0.0, 1.0, 0.0));
let projection_matrix = Matrix4::create_perspective(std::f64::consts::FRAC_PI_4, 1.0, 0.1, 100.0);
let character_positions = [[0.0, 0.0], [1.5, -0.5], [-1.0, 1.0]];
for position in character_positions {
vfx.queue_blob_shadow(&ToonBlobShadowOptions { x: position[0], z: position[1], radius: 0.5, ..ToonBlobShadowOptions::default() });
}
vfx.draw(gl, &view_matrix, &projection_matrix);
}ToonPlumeOptionsstruct traits Clone, Copy, Debug, Default
연기 기둥의 값.
Smoke plume options.
use vanilla::{ToonPlumeOptions, ToonVfx};
fn add_blast_plume(vfx: &mut ToonVfx) {
vfx.add_plume(&ToonPlumeOptions { x: 0.0, z: 0.0, height: 4.0, cap_radius: Some(1.6), stem_radius: Some(0.35), life: 5.0, ramp: 0, smoke_color: [0.3, 0.28, 0.26], key: Some(9), ..ToonPlumeOptions::default() });
}갓 반지름. (None 이면 높이의 0.4)
Cap radius. (0.4 of the height when None)
반환ReturnsOption<f64>
기둥 반지름. (None 이면 높이의 0.1)
Stem radius. (0.1 of the height when None)
반환ReturnsOption<f64>
이미 지난 초. (음수면 그만큼 늦게)
Seconds already elapsed. (if negative, delayed by that much)
반환Returnsf64
사건 열쇠. (이미 낸 열쇠면 내지 않음)
Event key. (not emitted if the key was already emitted)
반환ReturnsOption<u64>
ToonBeamOptionsstruct traits Clone, Copy, Debug, Default
회전체 빔의 값. (결은 start 에서 end 쪽으로 흐름)
Revolved beam options. (the grain flows from start toward end)
use vanilla::{Matrix4, ToonBeamOptions, ToonVfx, Vector3};
fn draw_beam(gl: &vanilla::GlContext, vfx: &mut ToonVfx) {
let view_matrix = Matrix4::create_look_at(Vector3::create(4.0, 3.0, 4.0), Vector3::create(0.0, 1.0, -4.0), Vector3::create(0.0, 1.0, 0.0));
let projection_matrix = Matrix4::create_perspective(std::f64::consts::FRAC_PI_4, 1.0, 0.1, 100.0);
let start = [0.0, 1.0, 0.0];
let end = [0.0, 1.0, -8.0];
vfx.queue_beam(&ToonBeamOptions { start, end, radius: 0.12, is_core: true, alpha: 1.0, brightness: 1.5, ..ToonBeamOptions::default() });
vfx.queue_beam(&ToonBeamOptions { start, end, radius: 0.3, alpha: 0.8, ramp: 0, wobble: 0.15, flow_speed: 6.0, grain_repeat: 0.6, seed: 2.0, ..ToonBeamOptions::default() });
vfx.draw(gl, &view_matrix, &projection_matrix);
}심이면 흰빛, 아니면 램프의 겉집.
White light if core, otherwise the outer layer of the ramp.
반환Returnsbool
겉이 일렁이는 몫. (반지름에 곱함)
Surface wobble amount. (multiplied by the radius)
반환Returnsf64
결과 일렁임의 시각. (None 이면 이 바탕의 시계)
Time for the grain and wobble. (this system's clock when None)
반환ReturnsOption<f64>
ToonRibbonOptionsstruct traits Clone, Debug, Default
리본의 값. (점열을 카메라 쪽으로 편 띠)
Ribbon options. (a strip spreading a point sequence toward the camera)
use vanilla::{ToonRibbonOptions, ToonVfx};
fn queue_swing_trail(vfx: &mut ToonVfx) {
let trail_points = vec![[-1.0, 1.0, 0.0], [-0.5, 1.3, -0.4], [0.0, 1.4, -0.6], [0.5, 1.3, -0.4], [1.0, 1.0, 0.0]];
vfx.queue_ribbon(ToonRibbonOptions { points: trail_points.clone(), width: 0.25, taper: 1.0, alpha: 1.0, brightness: 1.2, glow: Some([0.4, 0.8, 1.0]), ..ToonRibbonOptions::default() });
let flow = vfx.get_time() * 4.0;
vfx.queue_ribbon(ToonRibbonOptions { points: trail_points, width: 0.1, color: [1.0, 0.9, 0.6], alpha: 0.8, grain_repeat: 2.0, flow: Some(flow), ..ToonRibbonOptions::default() });
}0 이면 고른 너비, 1 이면 두 끝이 0.
0 is a uniform width, 1 makes both ends 0.
반환Returnsf64
색. (0 ~ 1 의 [r, g, b], 램프가 있으면 램프 색에 곱함)
Color. ([r, g, b] in 0 ~ 1, multiplied by the ramp color if there is a ramp)
반환Returns[f64; 3]
결의 자리. (None 이면 이 바탕의 시계)
Grain position. (this system's clock when None)
반환ReturnsOption<f64>
번짐 색. (주면 흰 심과 그 색 둘레와 테 색 가장자리로 덮는다, None 이면 더하는 빛)
Glow color. (when given, covers with a white core, that color around it and the rim color at the edges, additive light when None)
반환ReturnsOption<[f64; 3]>
덮는 꼴의 몫. (번짐 색이 없을 때 몸을 테 색으로 덮고 심은 색, 0 이면 더하는 빛만)
Cover look fraction. (without a glow color, covers the body with the rim color and the core with the color, 0 is additive light only)
반환Returnsf64
ToonLightningOptionsstruct traits Clone, Copy, Debug, Default
번개의 값. (축을 감아 내려가는 리본 여럿)
Lightning options. (several ribbons winding down around the axis)
use vanilla::{ToonLightningOptions, ToonVfx};
fn strike(vfx: &mut ToonVfx) {
vfx.queue_lightning(&ToonLightningOptions { start: [0.0, 4.0, 0.0], end: [0.0, 0.0, 0.0], radius: 0.15, count: 3, width: 0.06, turns: 1.5, color: [0.8, 0.9, 1.0], alpha: 1.0, brightness: 1.5, seed: Some(7.0), ..ToonLightningOptions::default() });
vfx.add_lightning(&ToonLightningOptions { start: [0.0, 4.0, 0.0], end: [0.5, 0.0, 0.2], life: 0.4, count: 2, width: 0.08, radius: 0.2, glow: Some([0.5, 0.7, 1.0]), key: Some(5), ..ToonLightningOptions::default() });
}리본 너비. (리본마다 0.7 ~ 1.3 배)
Ribbon width. (0.7 ~ 1.3 times per ribbon)
반환Returnsf64
리본 색. (0 ~ 1 의 [r, g, b], 램프가 있으면 램프 색에 곱함)
Ribbon color. ([r, g, b] in 0 ~ 1, multiplied by the ramp color if there is a ramp)
반환Returns[f64; 3]
리본의 램프 줄. (-1 이면 color 만)
Ramp row of the ribbons. (-1 for color only)
반환Returnsi32
꺾임의 시각. (None 이면 이 바탕의 시계, add_lightning 은 늘 이 바탕의 시계)
Time of the kinks. (this system's clock when None, add_lightning always uses this system's clock)
반환ReturnsOption<f64>
씨앗. (None 이면 queue_lightning 은 0, add_lightning 은 무작위)
Seed. (when None, 0 for queue_lightning and random for add_lightning)
반환ReturnsOption<f64>
사는 초와 나이. (add_lightning 만 읽는다, 나이가 음수면 그만큼 늦게 나타남)
Life in seconds and age. (read only by add_lightning, if the age is negative it appears that much later)
반환Returnsf64
나이. (add_lightning 만 읽는다, 음수면 그만큼 늦게 나타남)
Age. (Read only by add_lightning, appears that much later if negative)
반환Returnsf64
사건 열쇠. (add_lightning 만 읽는다, 이미 낸 열쇠면 내지 않음)
Event key. (read only by add_lightning, not emitted if the key was already emitted)
반환ReturnsOption<u64>
ToonGlintOptionsstruct traits Clone, Copy, Debug, Default
빛 점의 값. (파티클과 같은 꼴, 나이 없이 그 자리에)
Glint options. (the same look as particles, in place without an age)
use vanilla::{ToonGlintOptions, ToonVfx, ToonVfxLook};
fn queue_gem_glint(vfx: &mut ToonVfx) {
vfx.set_glint_capacity(32);
let twinkle = 0.5 + 0.5 * (vfx.get_time() * 6.0).sin();
vfx.queue_glint(&ToonGlintOptions { position: [0.5, 1.2, 0.0], size: 0.4 * twinkle, look: ToonVfxLook::Star, color: [1.0, 0.95, 0.7], angle: 0.3, brightness: 1.5, ..ToonGlintOptions::default() });
}색. (0 ~ 1 의 [r, g, b], 램프가 있으면 램프 색에 곱함)
Color. ([r, g, b] in 0 ~ 1, multiplied by the ramp color if there is a ramp)
반환Returns[f64; 3]
밝기 배. (꼴마다의 set_look_gain 배도 곱함)
Brightness multiplier. (the per-look set_look_gain multiplier is also applied)
반환Returnsf64
ToonFlashOptionsstruct traits Clone, Copy, Debug, Default
화면 섬광의 값. (뷰포트를 그 색으로 잠깐 덮고 빠르게 걷힘)
Screen flash options. (briefly covers the viewport with that color and quickly clears)
use vanilla::{ToonFlashOptions, ToonVfx};
fn flash_on_blast(vfx: &mut ToonVfx) {
vfx.add_flash(&ToonFlashOptions { color: [1.0, 0.9, 0.7], strength: 0.6, life: 0.12, key: Some(9), ..ToonFlashOptions::default() });
}사건 열쇠. (이미 낸 열쇠면 내지 않음)
Event key. (not emitted if the key was already emitted)
반환ReturnsOption<u64>
ToonRampColortrait
램프 한 칸의 색. ("#rrggbb" 글이나 0 ~ 1 의 [r, g, b], 원본 setRamps 가 둘 다 받는다)
Color of one ramp cell. ("#rrggbb" text or [r, g, b] in 0 ~ 1, the original setRamps accepts both)
use vanilla::ToonRampColor;
let from_text = "#ff8000".read_ramp_color();
let values: [f64; 3] = [1.0, 0.5, 0.0];
let from_values = values.read_ramp_color();
assert_eq!(from_text[0], 1.0);
assert!((from_text[1] - from_values[1]).abs() < 0.01);
assert_eq!(from_text[2], from_values[2]);0 ~ 1 의 [r, g, b] 읽기.
Reads [r, g, b] in 0 ~ 1.
반환Returns[f64; 3] 0 ~ 1 의 [r, g, b].[r, g, b] in 0 ~ 1.
ToonVfxCountsstruct traits Clone, Copy, Debug, Default, PartialEq, Eq
떠 있는 효과의 수.
Number of active effects.
use vanilla::{ToonFireballOptions, ToonParticleOptions, ToonVfx, ToonVfxRange};
fn is_quiet_after_one_second(vfx: &mut ToonVfx) -> bool {
vfx.add_fireball(&ToonFireballOptions { position: [0.0, 1.0, 0.0], radius: 1.0, life: 0.5, ..ToonFireballOptions::default() });
vfx.emit_particles(&ToonParticleOptions { count: 10, position: [0.0, 1.0, 0.0], life: ToonVfxRange::from(0.3), ..ToonParticleOptions::default() });
vfx.update(1.0);
let counts = vfx.get_active_counts();
counts.particle_count == 0 && counts.fireball_count == 0
}아직 살아 있을 수 있는 파티클 칸.
Particle slots that may still be alive.
반환Returnsusize
충격파 띠. (add_shockwave)
Shockwave rings. (add_shockwave)
반환Returnsusize
바닥 자국. (add_decal, queue_decal 로 넘긴 것은 세지 않음)
Floor decals. (add_decal, those passed with queue_decal are not counted)
반환Returnsusize
사는 동안 다시 꺾이는 번개. (add_lightning)
Lightning that re-bends during its life. (add_lightning)
반환Returnsusize
ToonVfxstruct
툰 3D GPU 효과의 바탕. (머리말 참고)
Base of toon 3D GPU effects. (see the header comment)
use vanilla::{create_box_geometry, Matrix4, MeshBuilder, ToonDecalOptions, ToonDrawOptions, ToonFireballOptions, ToonParticleOptions, ToonPartOptions, ToonRenderer, ToonShockwaveOptions, ToonVfx, ToonVfxDecalMode, ToonVfxLook, ToonVfxRange, ToonVfxShape, Vector3, TOON_VFX_DEFAULT_PARTICLE_CAPACITY};
fn draw_explosion(gl: &vanilla::GlContext) -> Result<(), String> {
let mut renderer = ToonRenderer::new(gl)?;
let mut builder = MeshBuilder::new();
builder.add_part(&create_box_geometry(8.0, 0.2, 8.0), &Matrix4::create_translation(0.0, -0.1, 0.0), "#708090", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
let floor_mesh = renderer.create_mesh(gl, &builder.read_arrays()).ok_or("floor mesh")?;
let mut vfx = ToonVfx::new(gl, TOON_VFX_DEFAULT_PARTICLE_CAPACITY)?;
vfx.set_ramps(&[vec!["#ffffff", "#ffe080", "#ff8020", "#a02010", "#301008"]]);
vfx.prepare(gl);
vfx.add_fireball(&ToonFireballOptions { position: [0.0, 0.8, 0.0], radius: 0.9, life: 1.2, ramp: 0, ..ToonFireballOptions::default() });
vfx.add_shockwave(&ToonShockwaveOptions { end_radius: 3.0, life: 0.6, ramp: 0, ..ToonShockwaveOptions::default() });
vfx.add_decal(&ToonDecalOptions { radius: 1.4, life: 8.0, heat_seconds: 1.5, mode: ToonVfxDecalMode::Scorch, ramp: 0, ..ToonDecalOptions::default() });
vfx.emit_particles(&ToonParticleOptions { count: 40, position: [0.0, 0.6, 0.0], shape: ToonVfxShape::Sphere, radius: 0.3, speed: ToonVfxRange::new(2.0, 5.0), gravity: 6.0, size: ToonVfxRange::new(0.05, 0.12), life: ToonVfxRange::new(0.4, 0.9), look: ToonVfxLook::Streak, stretch: 0.05, ramp: 0, is_grounded: true, ..ToonParticleOptions::default() });
let view_matrix = Matrix4::create_look_at(Vector3::create(4.0, 3.0, 5.0), Vector3::create(0.0, 0.5, 0.0), Vector3::create(0.0, 1.0, 0.0));
let projection_matrix = Matrix4::create_perspective(std::f64::consts::FRAC_PI_4, 1.0, 0.1, 100.0);
vfx.update(1.0 / 60.0);
renderer.begin_frame_with_matrices(gl, &view_matrix, &projection_matrix);
renderer.draw_mesh(gl, &floor_mesh, &Matrix4::create_identity(), ToonDrawOptions::default());
renderer.end_frame(gl);
vfx.draw(gl, &view_matrix, &projection_matrix);
Ok(())
}
생성. (셰이더와 메쉬, 파티클 버퍼를 지음, 아틀라스는 처음 그릴 때, 상한은 한꺼번에 떠 있는 파티클 수)
Constructor. (builds the shaders, meshes and particle buffer, the atlas on the first draw, the capacity is the number of particles alive at once)
- gl&GlContext
- 효과를 그릴 GL 컨텍스트.GL context to draw effects with.
- particle_capacityusize
- 한꺼번에 떠 있는 파티클의 상한. (1 이상으로 올림, 원본 기본값은 TOON_VFX_DEFAULT_PARTICLE_CAPACITY)Maximum number of particles alive at once. (Raised to at least 1, the original default is TOON_VFX_DEFAULT_PARTICLE_CAPACITY)
반환ReturnsResult<ToonVfx, String> 효과 바탕. 셰이더, 버퍼, 버텍스 어레이를 못 지으면 Err(오류 글).Effect base. Err(error text) if shaders, buffers or vertex arrays cannot be built.
짝Counterpart: vanilla.js ToonVfx.constructor
셰이더 소스. ((정점, 조각) 여덟 벌: 파티클, 불덩이, 띠, 자국, 빔, 기둥, 리본, 섬광, 공통 조각을 넣은 것)
Shader sources. (eight (vertex, fragment) pairs: particle, fireball, ring, decal, beam, plume, ribbon, flash, with the common fragment code inserted)
반환ReturnsVec<(String, String)> (정점, 조각) 셰이더 소스의 목록. (파티클, 불덩이, 띠, 자국, 빔, 기둥, 리본, 섬광 차례, 공통 조각을 넣은 것)List of (vertex, fragment) shader sources. (In the order particle, fireball, ring, decal, beam, plume, ribbon, flash, with the common chunks inserted)
짝Counterpart: vanilla.js ToonVfx.readProgramSources
색 램프 설정. (줄마다 흰 심에서 어둠으로 가는 "#rrggbb" 나 0 ~ 1 의 [r, g, b], 여덟 줄까지, 효과의 ramp 는 이 차례, 비면 기본 한 줄)
Sets the color ramps. (each row is "#rrggbb" or [r, g, b] in 0 ~ 1 going from a white core to dark, up to eight rows, an effect's ramp follows this order, one default row if empty)
- ramp_list&[Vec<C>]
- 줄마다 흰 심에서 어둠으로 가는 색들. (여덟 줄까지, 빈 줄은 버림)Colors per row going from a white core into darkness. (Up to eight rows, empty rows are dropped)
짝Counterpart: vanilla.js ToonVfx.setRamps
아틀라스를 미리 지어 두기. (처음 터질 때 멈칫하지 않게)
Prebuilds the atlas. (so it does not stall on the first burst)
- gl&GlContext
- GL 컨텍스트.GL context.
짝Counterpart: vanilla.js ToonVfx.prepare
파티클 상한 설정. (떠 있던 파티클은 지운다)
Sets the particle cap. (Clears alive particles)
- particle_capacityusize
- 한꺼번에 떠 있는 파티클의 상한. (1 이상)Upper limit of particles alive at once. (1 or more)
짝Counterpart: vanilla.js ToonVfx.setParticleCapacity
파티클 상한 반환.
Returns the particle cap.
반환Returnsusize 한꺼번에 떠 있는 파티클의 상한.Maximum number of particles alive at once.
짝Counterpart: vanilla.js ToonVfx.getParticleCapacity
내는 파티클 수의 몫 설정. (폰이나 가벼운 길에서 수만 줄임, 0 ~ 1, 내면 적어도 하나)
Sets the emitted particle count fraction. (reduces only the count on phones or the lite path, 0 ~ 1, at least one when emitting)
- count_ratiof64
- 내는 파티클 수에 곱하는 몫. (0 ~ 1)Fraction multiplied into the number of particles emitted. (0 ~ 1)
짝Counterpart: vanilla.js ToonVfx.setCountRatio
내는 파티클 수의 몫 반환.
Returns the emitted particle count fraction.
반환Returnsf64 내는 파티클 수에 곱하는 몫. (0 ~ 1)Fraction multiplied into the number of particles emitted. (0 ~ 1)
짝Counterpart: vanilla.js ToonVfx.getCountRatio
빛 점 상한 설정. (프레임마다 queue_glint 로 넘기는 수, 기본 96, 이번 프레임에 넘긴 빛 점은 지운다)
Sets the glint cap. (number passed with queue_glint per frame, default 96, clears the glints passed this frame)
- glint_capacityusize
- 프레임마다 넘기는 빛 점의 상한. (1 이상)Upper limit of light points submitted per frame. (1 or more)
짝Counterpart: vanilla.js ToonVfx.setGlintCapacity
빛 점 상한 반환.
Returns the glint cap.
반환Returnsusize 프레임마다 넘기는 빛 점의 상한.Upper limit of light points submitted per frame.
짝Counterpart: vanilla.js ToonVfx.getGlintCapacity
꼴마다 밝기 배 설정. (파티클과 빛 점의 밝기에 곱함, 기본 1)
Sets the brightness gain per look. (multiplied into particle and glint brightness, default 1)
- lookToonVfxLook
- 꼴. (ToonVfxLook)Look. (ToonVfxLook)
- gainf64
- 밝기 배. (0 이상, 기본 1)Brightness multiplier. (0 or more, default 1)
짝Counterpart: vanilla.js ToonVfx.setLookGain
꼴마다 밝기 배 반환.
Returns the brightness gain per look.
- lookToonVfxLook
- 꼴. (ToonVfxLook)Look. (ToonVfxLook)
반환Returnsf64 그 꼴의 밝기 배.Brightness multiplier of that look.
짝Counterpart: vanilla.js ToonVfx.getLookGain
사건 열쇠 적기. (열쇠가 없으면 늘 true, 처음 보는 열쇠면 적고 true, 이미 낸 열쇠면 false, clear 가 잊는다)
Records an event key. (Always true if there is no key, records it and returns true for a new key, false for an already emitted key, forgotten by clear)
- keyOption<u64>
- 사건 열쇠. (None 이면 늘 낸다)Event key. (Always fires if None)
반환Returnsbool 내도 되면 true, 이미 낸 열쇠면 false.true if it may fire, false if the key already fired.
짝Counterpart: vanilla.js ToonVfx.registerEventKey
효과 테의 색 설정. ([r, g, b] 0 ~ 1, 테를 두른 파티클과 번짐 리본의 가장자리, 기본은 ToonRenderer 의 기본 바깥선 색)
Sets the effect rim color. ([r, g, b] 0 ~ 1, edges of rimmed particles and glow ribbons, default is ToonRenderer's default outline color)
- rim_color[f64; 3]
- 테의 색. ([r, g, b] 0 ~ 1)Rim color. ([r, g, b] 0 ~ 1)
짝Counterpart: vanilla.js ToonVfx.setRimColor
효과 테의 색 반환.
Returns the effect rim color.
반환Returns[f64; 3] 효과 테의 색. ([r, g, b] 0 ~ 1)Color of the effect rim. ([r, g, b] 0 ~ 1)
짝Counterpart: vanilla.js ToonVfx.getRimColor
pub fn set_floor_height_reader(&mut self, floor_height_reader: Option<Box<dyn Fn(f64, f64) -> f64>>)#바닥 높이를 읽는 함수 설정. ((x, z) → 높이, None 이면 0)
Sets the floor height reader function. ((x, z) → height, 0 when None)
- floor_height_readerOption<Box<dyn Fn(f64, f64) -> f64>>
- (x, z) 로 바닥 높이를 돌려주는 함수. (None 이면 늘 0)Function returning the floor height for (x, z). (Always 0 if None)
짝Counterpart: vanilla.js ToonVfx.setFloorHeightReader
그 자리의 바닥 높이.
Floor height at that position.
- xf64
- 장면의 x.Scene x.
- zf64
- 장면의 z.Scene z.
반환Returnsf64 그 자리의 바닥 높이.Floor height at that position.
짝Counterpart: vanilla.js ToonVfx.readFloorHeight
이 바탕의 시계. (초)
This base's clock. (Seconds)
반환Returnsf64 이 바탕의 시계. (초, update 로 나아감)Clock of this base. (Seconds, advanced by update)
짝Counterpart: vanilla.js ToonVfx.getTime
떠 있는 효과의 수.
Number of active effects.
반환ReturnsToonVfxCounts 떠 있는 효과의 수. (ToonVfxCounts)Number of live effects. (ToonVfxCounts)
짝Counterpart: vanilla.js ToonVfx.getActiveCounts
다 지우기. (판이 바뀔 때, 사건 열쇠도 잊는다)
Clears everything. (When the board changes, also forgets event keys)
짝Counterpart: vanilla.js ToonVfx.clear
이번 프레임에 넘긴 것 비우기. (그린 뒤)
Clears the items passed this frame. (After drawing)
짝Counterpart: vanilla.js ToonVfx.clearQueue
한 프레임 나이 먹이기. (시계를 나아가게 하고 다 된 불덩이, 띠, 자국, 기둥, 번개, 섬광을 지움, 흔들림을 잦아들게 함)
Ages one frame. (Advances the clock, removes finished fireballs, rings, decals, plumes, lightning and flashes, damps the shake)
- delta_timef64
- 초.Seconds.
짝Counterpart: vanilla.js ToonVfx.update
파티클 내기. (floor 를 주면 그 높이에서, is_grounded 면 낸 자리의 바닥 높이에서 멈춘다)
Emits particles. (if floor is given they stop at that height, with is_grounded at the floor height of the emission point)
- options&ToonParticleOptions
- 내는 값. (ToonParticleOptions)Emission values. (ToonParticleOptions)
짝Counterpart: vanilla.js ToonVfx.emitParticles
불덩이 더하기. (잡음으로 끓는 구가 부풀며 식어 연기가 되고 위로 떠오름)
Adds a fireball. (a sphere boiling with noise swells, cools into smoke and rises)
- options&ToonFireballOptions
- 불덩이 값. (ToonFireballOptions)Fireball values. (ToonFireballOptions)
짝Counterpart: vanilla.js ToonVfx.addFireball
충격파 띠 더하기. (빠르게 퍼지다 천천히, 바깥 끝이 말려 오르고 찢기며 엷어짐, 밑의 바닥이 잠깐 밝아짐, 바닥 높이에 놓임)
Adds a shockwave ring. (spreads fast then slowly, the outer edge curls up, tears and fades, the floor below briefly brightens, placed at floor height)
- options&ToonShockwaveOptions
- 충격파 값. (ToonShockwaveOptions)Shockwave values. (ToonShockwaveOptions)
짝Counterpart: vanilla.js ToonVfx.addShockwave
바닥 자국 더하기. (그을음은 열기에서 식고 끝 1 초에 엷어짐, 바닥 높이에 놓임)
Adds a floor decal. (the scorch cools from heat and fades in the last 1 second, placed at floor height)
- options&ToonDecalOptions
- 자국 값. (ToonDecalOptions)Decal values. (ToonDecalOptions)
짝Counterpart: vanilla.js ToonVfx.addDecal
이번 프레임에만 그리는 바닥 자국 넘기기. (나이 대신 options.heat, 돎과 씨앗은 주지 않으면 0)
Passes a floor decal drawn only this frame. (options.heat instead of age, rotation and seed are 0 if not given)
- options&ToonDecalOptions
- 자국 값. (ToonDecalOptions, 나이 대신 heat(0 ~ 1)를 본다)Decal values. (ToonDecalOptions, reads heat (0 ~ 1) instead of age)
짝Counterpart: vanilla.js ToonVfx.queueDecal
이번 프레임에만 그리는 발밑 그늘 넘기기. (가운데 alpha 에서 바깥으로 둥글게 엷어지는 그늘, 바닥 높이에 놓임)
Passes a foot shadow drawn only this frame. (shade fading roundly outward from alpha at the center, placed at floor height)
- options&ToonBlobShadowOptions
- 그늘 값. (ToonBlobShadowOptions)Shadow values. (ToonBlobShadowOptions)
짝Counterpart: vanilla.js ToonVfx.queueBlobShadow
연기 기둥 더하기. (기둥이 솟고 갓이 말려 오르며 커지고, 갓 밑이 달아올랐다 식으며 엷어짐, 바닥 높이에 섬)
Adds a smoke plume. (the stem rises, the cap curls up and grows, the underside of the cap glows hot then cools and fades, stands at floor height)
- options&ToonPlumeOptions
- 연기 기둥 값. (ToonPlumeOptions)Smoke plume values. (ToonPlumeOptions)
짝Counterpart: vanilla.js ToonVfx.addPlume
이번 프레임에만 그리는 회전체 빔 넘기기.
Passes a revolved beam drawn only this frame.
- options&ToonBeamOptions
- 빔 값. (ToonBeamOptions, radius 와 alpha 가 0 보다 커야 넘어감)Beam values. (ToonBeamOptions, submitted only if radius and alpha are above 0)
짝Counterpart: vanilla.js ToonVfx.queueBeam
이번 프레임에만 그리는 리본 넘기기. (점 둘 이상)
Passes a ribbon drawn only this frame. (two or more points)
- optionsToonRibbonOptions
- 리본 값. (ToonRibbonOptions, 점이 둘 이상이고 width 와 alpha 가 0 보다 커야 넘어감)Ribbon values. (ToonRibbonOptions, submitted only with two or more points and width and alpha above 0)
짝Counterpart: vanilla.js ToonVfx.queueRibbon
이번 프레임의 번개 넘기기. (축을 감아 내려가는 리본 여럿, 0.08 초마다 다시 꺾임, 같은 시각과 씨앗이면 같은 꼴)
Passes this frame's lightning. (several ribbons winding down around the axis, re-kinks every 0.08 seconds, the same shape for the same time and seed)
- options&ToonLightningOptions
- 번개 값. (ToonLightningOptions, life, age, key 는 보지 않음)Lightning values. (ToonLightningOptions, life, age and key are not read)
짝Counterpart: vanilla.js ToonVfx.queueLightning
이번 프레임에만 그리는 빛 점 넘기기. (set_glint_capacity 까지, 기본 96)
Passes a glint drawn only this frame. (up to set_glint_capacity, default 96)
- options&ToonGlintOptions
- 빛 점 값. (ToonGlintOptions)Glint values. (ToonGlintOptions)
짝Counterpart: vanilla.js ToonVfx.queueGlint
사는 동안 다시 꺾이는 번개 더하기. (그릴 때마다 queue_lightning 으로 넘긴다, 끝 0.1 초에 엷어짐, 나이가 음수면 그만큼 늦게 나타남)
Adds lightning that re-kinks over its life. (passed with queue_lightning on every draw, fades in the last 0.1 seconds, if the age is negative it appears that much later)
- options&ToonLightningOptions
- 번개 값. (ToonLightningOptions, life, age, key 도 읽는다)Lightning values. (ToonLightningOptions, life, age and key are read too)
짝Counterpart: vanilla.js ToonVfx.addLightning
화면 섬광 더하기. (뷰포트를 그 색으로 잠깐 덮고 빠르게 걷힘)
Adds a screen flash. (briefly covers the viewport with that color and quickly clears)
- options&ToonFlashOptions
- 섬광 값. (ToonFlashOptions)Flash values. (ToonFlashOptions)
짝Counterpart: vanilla.js ToonVfx.addFlash
카메라 흔들림 더하기. (장면 길이의 최대 오프셋, 엔진 Shaker 가 위상이 다른 두 사인파와 지수 감쇠로 셈, 흔들리는 중이면 센 쪽)
Adds camera shake. (Maximum offset in scene length, computed by the engine Shaker with two phase-shifted sine waves and exponential decay, the stronger one if already shaking)
- strengthf64
- 흔들림의 최대 오프셋. (장면 길이)Maximum offset of the shake. (Scene length)
짝Counterpart: vanilla.js ToonVfx.addShake
지금의 카메라 흔들림. (장면 길이, x 는 카메라 오른쪽, y 는 카메라 위쪽으로 카메라 자리와 보는 곳에 같이 더한다)
Current camera shake. (Scene length, x toward the camera's right and y toward the camera's up, added to both the camera position and the look-at point)
반환ReturnsVector2 흔들림 오프셋. (장면 길이, x 는 카메라 오른쪽, y 는 카메라 위쪽)Shake offset. (Scene length, x is the camera's right, y is the camera's up)
짝Counterpart: vanilla.js ToonVfx.readShake
카메라가 흔들리는 중인지.
Whether the camera is shaking.
반환Returnsbool 흔들리는 중이면 true.true while shaking.
짝Counterpart: vanilla.js ToonVfx.isShaking
pub fn draw(&mut self, gl: &GlContext, view_matrix: &Matrix4, projection_matrix: &Matrix4)#그리기. (바닥 자국, 띠, 연기 기둥, 불덩이, 빔, 리본, 파티클, 섬광 차례, 사는 번개는 이번 프레임의 리본으로 넘김, 넘긴 것은 그린 뒤 비움)
Draws. (in the order floor decals, rings, smoke plumes, fireballs, beams, ribbons, particles, flashes, living lightning is passed as this frame's ribbons, passed items are cleared after drawing)
- gl&GlContext
- GL 컨텍스트.GL context.
- view_matrix&Matrix4
- 카메라의 보기 행렬.View matrix of the camera.
- projection_matrix&Matrix4
- 투영 행렬. (원근이나 직교)Projection matrix. (Perspective or orthographic)
짝Counterpart: vanilla.js ToonVfx.draw
다 쓴 뒤 지우기.
Deletes after use.
- gl&GlContext
- 만들 때 쓴 GL 컨텍스트.GL context used at creation.
짝Counterpart: vanilla.js ToonVfx.destroy
상수Constants
색 램프 줄의 수 상한. (아틀라스의 램프 칸 하나에 여덟 줄)
Maximum number of color ramp rows. (Eight rows in one ramp cell of the atlas)
반환Returnsusize
짝Counterpart: vanilla.js TOON_VFX_MAXIMUM_RAMPS
한꺼번에 떠 있는 파티클의 기본 상한.
Default maximum number of particles alive at once.
반환Returnsusize
짝Counterpart: vanilla.js TOON_VFX_DEFAULT_PARTICLE_CAPACITY
ToonVfxSlotenum traits Clone, Copy, Debug, PartialEq, Eq
아틀라스 오른쪽 반의 칸. (셰이더의 readSlot 번호, 6, 7, 11 ~ 15 는 비어 있다)
Cells of the atlas's right half. (the shader's readSlot index, 6, 7, 11 ~ 15 are empty)
| 이름Name | 설명Description |
|---|---|
Soft | 부드러운 알갱이.Soft grain. |
Streak | 불꽃 줄기. (v 1 쪽이 머리)Flame streak. (The v 1 side is the head) |
Star | 빛살.Light ray. |
ShockBand | 충격 띠.Shock band. |
BeamGrain | 빔 결.Beam grain. |
Scorch | 그을음. (알파는 어둡게 덮는 몫, 빨간 채널은 열기)Scorch. (Alpha is the darkening cover fraction, the red channel is heat) |
Ramps | 색 램프 여덟 줄.Eight color ramp rows. |
Dent | 패인 땅.Cratered ground. |
Glow | 넓은 둘레 빛.Wide halo glow. |
칸 번호.
Cell index.
반환Returnsusize 칸 번호. (셰이더의 readSlot 번호)Cell number. (The readSlot number of the shader)
ToonVfxLookenum traits Clone, Copy, Debug, PartialEq, Eq
파티클의 꼴. (셰이더의 look 번호와 같은 차례)
Particle look. (same order as the shader's look index)
| 이름Name | 설명Description |
|---|---|
Soft | 부드러운 알갱이. (더하는 빛)Soft grain. (Additive light) |
Streak | 속도 쪽으로 늘인 불꽃 줄기. (더하는 빛, stretch 가 속도에 곱하는 늘임)Flame streak stretched along velocity. (Additive light, stretch is the stretch multiplied by velocity) |
Smoke | 연기 플립북. (덮기)Smoke flipbook. (Covering) |
Star | 빛살. (더하는 빛)Light ray. (Additive light) |
Ember | 깜빡이는 불씨. (더하는 빛)Flickering ember. (Additive light) |
Glow | 넓은 둘레 빛. (더하는 빛)Wide halo glow. (Additive light) |
Grit | 빛을 내지 않는 돌과 흙 알갱이. (덮기)Non-emissive rock and dirt grain. (Covering) |
ToonVfxShapeenum traits Clone, Copy, Debug, PartialEq, Eq
파티클을 내는 꼴.
Particle emission shape.
| 이름Name | 설명Description |
|---|---|
Point | 한 점에서 모든 쪽으로.From one point in all directions. |
Sphere | 반지름 radius 공 안에서 바깥쪽으로.Outward within a ball of radius radius. |
Ring | 바닥과 나란한 고리 위에서 바깥쪽으로.Outward on a ring parallel to the floor. |
Disc | 바닥과 나란한 원판 안에서 바깥쪽으로.Outward within a disc parallel to the floor. |
Cone | direction 을 가운데로 spread 각 안의 원뿔.Cone within the spread angle centered on direction. |
Line | direction 쪽으로 length 까지의 선 위(둘레 radius 안)에서 direction 쪽으로.Toward direction, from a line along direction up to length (within radius around it). |
ToonVfxDecalModeenum traits Clone, Copy, Debug, PartialEq, Eq
바닥 자국의 꼴.
Floor decal mode.
| 이름Name | 설명Description |
|---|---|
Scorch | 알파로 어둡게 덮고 빨간 채널의 금에서 열기가 식는다.Darkens by alpha, and heat cools in the cracks of the red channel. |
Glow | 칸의 알파만큼 더하는 빛.Additive light by the cell's alpha. |
Ring | 둘레로 흐르는 잡음 테. (ring 이 (테 반지름, 테 너비, 잡음 잘기, 흐르는 빠르기) 의 반지름 몫)Noise rim flowing around the circumference. (ring is the radius fractions of (rim radius, rim width, noise fineness, flow speed)) |
Stain | 칸의 알파만큼 tint 색으로 덮고, 칸의 가운데 짙기(테 둘레)는 테 색(set_rim_color) 쪽으로 물든다. (밝은 바닥의 얼룩, 서리)Covers with the tint color by the cell's alpha, and the cell's center density (around the rim) is tinted toward the rim color (set_rim_color). (stains on bright floors, frost) |
Sheen | 칸의 알파 몸을 tint 로 덮고 몸 가장자리에 흰 윤을 두른다. (기름 윤)Covers the cell's alpha body with tint and puts a white sheen around the body's edges. (Oil sheen) |
Shade | 가운데에서 바깥으로 둥글게 엷어지는 그늘. (알파만큼 어둡게 덮음, 칸은 보지 않음, 발밑 그늘 queue_blob_shadow)Shade fading roundly from the center outward. (darkens by alpha, ignores the cell, foot shadow queue_blob_shadow) |