graphics3d/toon/toonscreenoutline
툰 화면 공간 바깥선. (vanilla.js graphics3d/toon/toonscreenoutline.js 의 ToonScreenOutline)
- 노멀, 선 번호, 깊이를 선의 판에 그리고, 바로 이웃 사이의 경계에서 선을 잡아 가는 선은 둘레 칸을 바로 보고, 굵은 선은 점프 플러딩으로 넓힌 뒤 거리로 덮는 몫을 셈해 섞는다.
- 선의 판: ToonRenderer 의 create_mesh 결과를 같은 행렬로 한 번 더 그려 노멀(팔면체 접기), 선 번호(14 비트), 꼴(바깥 선, 꺾임 선을 켤지)과 깊이를 쓴다.
- 잡기: 화소와 바로 이웃 넷 사이의 경계마다 한 번 본다. 선은 화소가 아니라 화소 사이의 경계 가운데에 선다. (같은 경계를 두 번 긋지 않는다) 바깥 선은 빈 곳과 맞닿은 실루엣, 다른 번호와 맞닿은 곳, 같은 번호라도 가린 화소가 가려진 화소의 접평면에서 깊이 문턱과 오차 여유보다 떨어진 곳(가려진 실루엣)이다. 꺾임 선은 같은 번호 안에서 이웃한 두 노멀이 꺾임 각보다 더 벌어진 곳이다. 화소 하나 사이의 노멀만 보므로 둥근 면의 실루엣 둘레나 비스듬한 면에 띠가 서지 않는다. 깊이를 접평면 거리로 견주므로 비스듬히 보는 바닥에 가짜 선이 서지 않는다. 문턱에 잰 오차(노멀 8 비트 각 오차 x 두 자리 사이 거리, 꺾임의 화소 한 칸 x 사인, 깊이 24 비트 한 칸) x 배율을 더해 먼 것도 같은 뜻이 되고, 나란한 낮은 턱은 화소 한 칸보다 낮아도 잡힌다.
- 가는 선(굵기 약 3.24 픽셀까지): 씨앗 고르기와 같은 차례로 화소마다 첫 경계 쪽(R8UI 한 바이트)을 고르고, 섞기가 둘레 3 x 3 화소의 씨앗을 점프 플러딩 마지막 걸음과 같은 차례로 보아 가장 가까운 것까지의 거리를 잰다. 화면 전체 패스가 씨앗 쪽 판 하나와 섞기 하나다. (모바일 타일 GPU 에서 패스 수와 판 대역폭이 굵은 선 길의 몇 분의 1)
- 넓히기(굵은 선): 경계 토막까지의 거리를 점프 플러딩으로 퍼뜨린다. 굵기에 상관없이 걸음 수는 log2 이고, 바깥 선과 꺾임 선은 따로 퍼뜨려 굵기를 따로 준다.
- 섞기: 그리는 영역의 화소마다 가장 가까운 경계까지의 거리로 clamp(굵기 / 2 - 거리 + 0.5, 0, 1) 만큼 덮는다. (가장자리가 부드럽고, 선의 판을 줄여도 늘인 선이 점선이 되지 않는다)
- 모형마다: ToonLineDrawOptions 의 has_screen_outline 이 false 면 그 모형은 선을 내지 않고 뒤의 선만 가린다. has_crease_line 이 false 면 꺾임 선만 끈다.
- 번호마다 색: set_line_color 로 번호마다 선 색을 준다. (언리얼 Custom Stencil 꼴, 맞닿은 선은 앞쪽 번호의 색, 표에 없는 번호와 표가 빈 때는 set_color 의 색 그대로)
- 굵기: set_width 와 set_crease 의 굵기는 선 하나의 굵기다. (경계를 가운데로 양쪽에 반씩) 단위는 ToonOutlineWidthUnit, 한 픽셀 밑으로 내리지 않는다.
- 깊이: 투영 행렬로 직교와 원근을 가리고, 깊이를 보기 공간 자리로 풀어 견준다. (화면 사각형처럼 클립 x, y 를 옮긴 투영도 된다)
- 값: set_resolution_scale 로 섞기 앞의 모든 판(선의 판, 가면, 씨앗, 넓히기 판)을 줄인다. (기본 1 은 그리는 영역 그대로, 줄이면 가는 선은 선의 판 해상도에서 덮는 몫 판 하나를 셈해 쌍선형으로 한 번 읽어 섞는다)
- 사용: 매 프레임 begin_line_ids(gl, 보기, 투영) → draw_mesh / draw_mesh_instanced → end_line_ids(gl) (씨앗과 넓히기까지 셈) → 툰 몸 그리기 → draw_outline(gl). begin_line_ids 는 그때의 뷰포트를 그리는 영역으로 적어 두고, 선의 판을 그 크기에 맞춰 짓는다. end_line_ids 와 draw_outline 이 프레임버퍼, 뷰포트, 상태를 돌린다. ToonDrawQueue::set_screen_outline 으로 맡기면 그리기 줄이 이 차례를 스스로 한다. (엔진 2D 그리기 사이에 끼울 때, 그 전에 Graphic 의 묶음을 내보내고 끝에 restore_render_state)
- 인스턴스마다의 번호는 ToonInstance 의 line_id 다. (원본 인스턴스 객체의 lineId, None 이면 공통 번호)
Toon screen-space outline. (ToonScreenOutline of vanilla.js graphics3d/toon/toonscreenoutline.js)
- It draws normals, line ids and depth into the line buffer, finds lines at the boundaries between direct neighbors, then blends: thin lines look at the surrounding cells directly, thick lines are widened by jump flooding and the coverage is worked out from the distance.
- Line buffer: draws the create_mesh result of ToonRenderer once more with the same matrices and writes the normal (octahedron folded), the line id (14 bits), the shape (whether contour and crease lines are on) and the depth.
- Finding: looks once at every boundary between a pixel and its four direct neighbors. A line stands on the boundary between pixels, not on a pixel. (the same boundary is never drawn twice) A contour line is a silhouette touching empty space, a place touching another id, or, even with the same id, a place where the occluding pixel is farther than the depth threshold and error margin from the tangent plane of the occluded pixel (an occluded silhouette). A crease line is a place inside the same id where two neighboring normals differ by more than the crease angle. Only the normals one pixel apart are looked at, so no band stands around the silhouette of a round surface or on a slanted surface. Depth is compared as a tangent plane distance, so no false lines stand on a floor seen at a slant. The measured error (normal 8-bit angle error x distance between the two positions, one pixel of the crease x sine, one step of 24-bit depth) x the margin is added so far things mean the same, and low parallel steps are caught even when lower than one pixel.
- Thin line (up to a width of about 3.24 pixels): picks the first boundary side per pixel (R8UI, one byte) in the same order as the seed pick, and the blend reads the seeds of the 3 x 3 pixels around in the same order as the last jump flooding step to measure the distance to the nearest one. The full-screen passes are one side buffer and one blend. (on mobile tile GPUs the pass count and buffer bandwidth are a fraction of the thick line path)
- Widening (thick line): spreads the distance to the boundary segment by jump flooding. The step count is log2 whatever the width, and contour and crease lines are spread separately so they get separate widths.
- Blend: for each pixel of the drawing area it covers clamp(width / 2 - distance + 0.5, 0, 1) from the distance to the nearest boundary. (soft edges, and shrinking the line buffer does not turn widened lines into dotted lines)
- Per model: if has_screen_outline of ToonLineDrawOptions is false the model draws no line and only hides lines behind it. If has_crease_line is false only the crease line is off.
- Color per id: set_line_color gives each id a line color. (Unreal Custom Stencil style, a touching line takes the color of the front id, ids not in the table and an empty table keep the color of set_color)
- Width: the width of set_width and set_crease is the width of one line. (half on each side of the boundary) The unit is ToonOutlineWidthUnit, never below one pixel.
- Depth: the projection matrix tells orthographic from perspective, and depth is unpacked to view space positions for comparing. (projections that shift clip x, y like a screen rectangle also work)
- Scale: set_resolution_scale shrinks every buffer before the blend (line buffer, mask, seed, widening buffers). (the default 1 is the drawing area as it is, and below 1 a thin line works out one coverage buffer at the line buffer resolution and reads it bilinearly once to blend)
- Use: every frame begin_line_ids(gl, view, projection) → draw_mesh / draw_mesh_instanced → end_line_ids(gl) (works out the seeds and widening) → toon body drawing → draw_outline(gl). begin_line_ids notes the viewport of that moment as the drawing area and builds the line buffer to that size. end_line_ids and draw_outline restore the framebuffer, viewport and state. Handing it to ToonDrawQueue::set_screen_outline lets the draw queue do this order by itself. (when inserting between engine 2D drawing, flush the Graphic batch before and call restore_render_state after)
- The id per instance is line_id of ToonInstance. (lineId of the original instance object, None means the common id)
use vanilla::{create_box_geometry, Matrix4, MeshBuilder, ToonDrawOptions, ToonLineDrawOptions, ToonOutlineWidthUnit, ToonPartOptions, ToonRenderer, ToonScreenOutline, Vector3};
fn draw_outlined_box(gl: &vanilla::GlContext) -> Result<(), String> {
let mut renderer = ToonRenderer::new(gl)?;
let mut outline = ToonScreenOutline::new(gl)?;
outline.set_width(2.0, ToonOutlineWidthUnit::Pixel);
outline.set_crease(50.0, 1.0, 0.8);
let mut builder = MeshBuilder::new();
builder.add_part(&create_box_geometry(1.0, 1.0, 1.0), &Matrix4::create_identity(), "#e0c8a8", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
let mesh = renderer.create_mesh(gl, &builder.read_arrays()).ok_or("mesh failed")?;
let view_matrix = Matrix4::create_look_at(Vector3::create(2.0, 2.0, 3.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 model_matrix = Matrix4::create_identity();
if outline.begin_line_ids(gl, &view_matrix, &projection_matrix) {
outline.draw_mesh(gl, &mesh, &model_matrix, 1, ToonLineDrawOptions::default());
outline.end_line_ids(gl);
}
renderer.begin_frame_with_matrices(gl, &view_matrix, &projection_matrix);
renderer.draw_mesh(gl, &mesh, &model_matrix, ToonDrawOptions::default());
renderer.end_frame(gl);
outline.draw_outline(gl);
Ok(())
}
ToonLineDrawOptionsstruct traits Clone, Copy, Debug, Default
번호를 그릴 때의 꼴. (원본 drawMesh 의 options)
Options for drawing IDs. (the original drawMesh options)
use vanilla::{create_box_geometry, create_octahedron_geometry, Matrix4, MeshBuilder, ToonLineDrawOptions, ToonPartOptions, ToonRenderer, ToonScreenOutline, Vector3};
fn draw_floor_and_crystal(gl: &vanilla::GlContext, renderer: &ToonRenderer, outline: &mut ToonScreenOutline) -> Option<()> {
let part_options = ToonPartOptions { has_outline: false, ..ToonPartOptions::default() };
let mut floor_builder = MeshBuilder::new();
floor_builder.add_part(&create_box_geometry(6.0, 0.2, 6.0), &Matrix4::create_translation(0.0, -0.1, 0.0), "#506070", part_options);
let floor_mesh = renderer.create_mesh(gl, &floor_builder.read_arrays())?;
let mut crystal_builder = MeshBuilder::new();
crystal_builder.add_part(&create_octahedron_geometry(0.5), &Matrix4::create_translation(0.0, 0.5, 0.0), "#90d0ff", part_options);
let crystal_mesh = renderer.create_mesh(gl, &crystal_builder.read_arrays())?;
let view_matrix = Matrix4::create_look_at(Vector3::create(3.0, 3.0, 4.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);
if outline.begin_line_ids(gl, &view_matrix, &projection_matrix) {
outline.draw_mesh(gl, &floor_mesh, &Matrix4::create_identity(), 1, ToonLineDrawOptions { has_screen_outline: false, ..ToonLineDrawOptions::default() });
outline.draw_mesh(gl, &crystal_mesh, &Matrix4::create_identity(), 2, ToonLineDrawOptions { has_crease_line: false, ..ToonLineDrawOptions::default() });
outline.end_line_ids(gl);
}
Some(())
}뼈대 모형의 본 행렬. (본마다 수 16, TOON_MAXIMUM_JOINTS 개까지, ToonRenderer::draw_mesh 와 같은 자세로 주고, None 이면 자세 없이 그린다)
Joint matrices of a skinned model. (16 numbers per joint, up to TOON_MAXIMUM_JOINTS, give the same pose as ToonRenderer::draw_mesh, None draws without a pose)
반환ReturnsOption<&'a [f32]>
화면 밖이면 건너뛸지. (경계 구가 절두체 밖이면 그리지 않는다, 기본 true)
Whether to skip when off screen. (not drawn if the bounding sphere is outside the frustum, default true)
반환Returnsbool
몸 번호 버퍼의 일부만. (부품에 다른 번호를 줄 때, 시작 번호와 수, 수가 None 이면 끝까지)
Only part of the body index buffer. (for giving a part a different ID, start index and count, to the end if the count is None)
반환Returnsusize
몸 번호 버퍼에서 그릴 수. (None 이면 index_start 부터 끝까지)
Number of body indices to draw. (None means from index_start to the end)
반환ReturnsOption<usize>
감기를 뒤집어 그릴지. (None 이면 모형 행렬의 행렬식이 음수일 때, 인스턴스는 None 이면 뒤집지 않음)
Whether to draw with the winding flipped. (when None, flipped if the model matrix determinant is negative, for instances None means not flipped)
반환ReturnsOption<bool>
바깥 선을 낼지. (false 면 선은 내지 않고 뒤의 선만 가린다)
Whether to output outer lines. (when false, no line is output and only the lines behind are hidden)
반환Returnsbool
ToonLineTargetstruct
선의 판. (선의 판 해상도의 노멀과 번호 RGBA8, 깊이 24, 가는 선의 씨앗 쪽 판 R8UI, 굵은 선을 그을 때 짓는 씨앗 RGBA16UI 와 넓히기 판 RGBA16UI 둘, jump_flood_index 는 넓히기를 마친 쪽)
Line buffer. (normal and id RGBA8 at the line buffer resolution, depth 24, the thin line side buffer R8UI, the seed RGBA16UI and two widening buffers RGBA16UI built when a thick line is drawn, jump_flood_index is the side where widening ended)
use vanilla::ToonScreenOutline;
fn print_line_target(outline: &ToonScreenOutline) {
if let Some(line_target) = outline.get_line_target() {
println!("line {} x {}, jump flood {} x {}", line_target.width, line_target.height, line_target.jump_flood_width, line_target.jump_flood_height);
}
}선의 판 프레임버퍼. (노멀과 번호 텍스처, 깊이 텍스처)
Line target framebuffer. (normal and ID texture, depth texture)
반환ReturnsGlFramebuffer
노멀과 번호 텍스처. (RGBA8, 노멀은 팔면체로 접어 rg, 번호와 꼴은 ba)
Normal and ID texture. (RGBA8, the normal octahedrally encoded in rg, the ID and flags in ba)
반환ReturnsGlTexture
가는 선의 씨앗 쪽 판 프레임버퍼.
Framebuffer of the thin line side buffer.
반환ReturnsGlFramebuffer
가는 선의 씨앗 쪽 판. (R8UI, 아래 3 비트 바깥 선, 위 3 비트 꺾임 선의 첫 경계 쪽 0 없음, 1 오른쪽, 2 왼쪽, 3 위, 4 아래)
Thin line side buffer. (R8UI, the low 3 bits are the contour line and the high 3 bits the crease line first boundary side: 0 none, 1 right, 2 left, 3 up, 4 down)
반환ReturnsGlTexture
씨앗 판 프레임버퍼. (굵은 선을 처음 그을 때 짓는다, 그 전에는 None)
Seed buffer framebuffer. (built the first time a thick line is drawn, None before)
반환ReturnsOption<GlFramebuffer>
씨앗 텍스처. (RGBA16UI, rg 는 바깥 선, ba 는 꺾임 선, 굵은 선을 긋기 전에는 None)
Seed texture. (RGBA16UI, rg is the contour line and ba the crease line, None before a thick line is drawn)
반환ReturnsOption<GlTexture>
넓히기 판 프레임버퍼 둘. (번갈아 쓴다, 굵은 선을 긋기 전에는 빔)
Two widening buffer framebuffers. (used alternately, empty before a thick line is drawn)
반환ReturnsVec<GlFramebuffer>
넓히기 판 텍스처 둘. (RGBA16UI, 굵은 선을 긋기 전에는 빔)
Two widening buffer textures. (RGBA16UI, empty before a thick line is drawn)
반환ReturnsVec<GlTexture>
넓히기를 마친 쪽. (jump_flood_textures 의 차례, 0 이나 1, 넓히지 않았으면 None, 원본 -1)
Side where widening ended. (index into jump_flood_textures, 0 or 1, None when nothing was widened, -1 in the original)
반환ReturnsOption<usize>
줄인 선의 판의 가는 선 덮는 몫 프레임버퍼. (줄여 가는 선을 처음 그을 때 짓는다, 그 전에는 None)
Framebuffer of the thin line coverage buffer of the reduced line buffer. (built the first time a reduced thin line is drawn, None before)
반환ReturnsOption<GlFramebuffer>
줄인 선의 판의 가는 선 덮는 몫 판. (RGBA8 곱한 색, 쌍선형, 줄여 가는 선을 긋기 전에는 None)
Thin line coverage buffer of the reduced line buffer. (RGBA8 premultiplied color, bilinear, None before a reduced thin line is drawn)
반환ReturnsOption<GlTexture>
이번 프레임의 길. (end_line_ids 가 정한다)
Path of this frame. (set by end_line_ids)
반환ReturnsToonOutlinePath
선의 판 너비. (그리는 영역 x set_resolution_scale 의 몫, 픽셀)
Line buffer width. (drawing area x the fraction of set_resolution_scale, in pixels)
반환Returnsi32
선의 판 높이. (그리는 영역 x set_resolution_scale 의 몫, 픽셀)
Line buffer height. (drawing area x the fraction of set_resolution_scale, in pixels)
반환Returnsi32
넓히기 판 너비. (선의 판과 같다, 픽셀)
Widening buffer width. (same as the line buffer, in pixels)
반환Returnsi32
넓히기 판 높이. (선의 판과 같다, 픽셀)
Widening buffer height. (same as the line buffer, in pixels)
반환Returnsi32
ToonScreenOutlinestruct
툰 화면 공간 바깥선. (머리말 참고)
Toon screen-space outline. (see the header comment)
use vanilla::{ToonOutlineWidthUnit, ToonScreenOutline};
fn create_silhouette_outline(gl: &vanilla::GlContext) -> Result<ToonScreenOutline, String> {
let mut outline = ToonScreenOutline::new(gl)?;
outline.set_color([0.1, 0.08, 0.12, 1.0]);
outline.set_width(3.0, ToonOutlineWidthUnit::Pixel);
outline.set_crease(180.0, 1.0, 1.0);
outline.set_resolution_scale(0.5);
Ok(outline)
}생성. (아홉 프로그램과 빈 버텍스 어레이를 짓는다, 선의 판은 첫 begin_line_ids 에서, 색 공간은 엔진의 것)
Creation. (builds nine programs and an empty vertex array, the line buffer is built at the first begin_line_ids, the color space is the engine's)
- gl&GlContext
- 툰 렌더러와 같은 컨텍스트.The same context as the toon renderer.
반환ReturnsResult<ToonScreenOutline, String> 새 화면 공간 바깥선. 셰이더를 짓지 못하거나 버텍스 어레이를 못 만들면 Err(오류 글).New screen-space outline. Err(error message) if a shader cannot be built or the vertex array cannot be created.
짝Counterpart: vanilla.js ToonScreenOutline.constructor
셰이더 소스. ((정점, 조각) 아홉 벌: 번호, 씨앗, 모으기, 넓히기, 섞기, 가는 선의 씨앗 쪽 판, 가는 선 섞기, 줄인 판의 가는 선 덮는 몫, 덮는 몫 판 섞기)
Shader sources. (nine (vertex, fragment) pairs: id, seed, gather, widening, blend, thin line side buffer, thin line blend, coverage of a reduced buffer thin line, coverage buffer blend)
- color_spaceColorSpace
- 색 공간. (원본 기본은 엔진의 색 공간, Linear 면 섞기 셰이더에 #define VANILLA_COLOR_SPACE_LINEAR 1 이 들어간다)Color space. (original default is the engine's color space; with Linear the composite shader gets #define VANILLA_COLOR_SPACE_LINEAR 1)
반환Returns[(String, String); 9] (정점 셰이더, 조각 셰이더) 아홉. (번호, 씨앗, 모으기, 넓히기, 섞기, 가는 선의 씨앗 쪽 판, 가는 선 섞기, 줄인 판의 가는 선 덮는 몫, 덮는 몫 판 섞기, 번호 셰이더의 어트리뷰트 자리는 TOON_ATTRIBUTE_LOCATIONS)Nine (vertex shader, fragment shader). (id, seed, gather, widening, blend, thin line side buffer, thin line blend, coverage of a reduced buffer thin line, coverage buffer blend, the attribute locations of the id shader are TOON_ATTRIBUTE_LOCATIONS)
짝Counterpart: vanilla.js ToonScreenOutline.readProgramSources
pub fn new_with_options(gl: &GlContext, options: ToonScreenOutlineOptions) -> Result<ToonScreenOutline, String>#꼴을 주어 생성. (원본 new ToonScreenOutline(gl, options))
Creation with options. (original new ToonScreenOutline(gl, options))
- gl&GlContext
- 툰 렌더러와 같은 컨텍스트.The same context as the toon renderer.
- optionsToonScreenOutlineOptions
- 색 공간. (ToonScreenOutlineOptions, HDR 출력에서 선 색을 선형으로 바꾸는 곡선)Color space. (ToonScreenOutlineOptions, the curve that converts the line color to linear for HDR output)
반환ReturnsResult<ToonScreenOutline, String> 새 화면 공간 바깥선. 셰이더를 짓지 못하거나 버텍스 어레이를 못 만들면 Err(오류 글).New screen-space outline. Err(error message) if a shader cannot be built or the vertex array cannot be created.
색 공간 반환. (원본 getColorSpace, 생성 때 정한 값, HDR 출력에서 선 색을 선형으로 바꾸는 곡선, Gamma 는 pow 2.2, Linear 는 sRGB 표준 곡선)
Returns the color space. (original getColorSpace, fixed at creation, the curve that converts the line color to linear for HDR output, pow 2.2 for Gamma and the standard sRGB curve for Linear)
반환ReturnsColorSpace ColorSpace::Gamma 나 ColorSpace::Linear.ColorSpace::Gamma or ColorSpace::Linear.
짝Counterpart: vanilla.js ToonScreenOutline.getColorSpace
선 색 설정. (sRGB 0 ~ 1 과 알파, 바깥 선과 꺾임 선이 같이 쓴다)
Sets the line color. (sRGB 0 ~ 1 and alpha, shared by outer lines and crease lines)
- color[f64; 4]
- [r, g, b, a] 의 sRGB.sRGB [r, g, b, a].
짝Counterpart: vanilla.js ToonScreenOutline.setColor
번호마다 선 색 설정. (그 번호의 모형이 앞에 선 바깥 선과 꺾임 선을 이 색으로, 표에 없는 번호는 set_color 의 색 그대로)
- 언리얼 Custom Stencil 의 후처리 바깥선처럼 선의 판에 이미 있는 번호로 색을 고른다. 고른 모형을 강조하거나 편마다 색을 달리할 때.
- 표는 선 번호 전부(1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID)를 덮는 128 x 128 찾기 텍스처다. 넣는 번호 수에 상한이 없고, 화소마다 한 번 읽는다.
- 두 번호가 맞닿은 선은 앞(카메라에 가까운) 쪽 번호의 색이다. 색은 sRGB 8 비트로 담고, 알파 0 은 1/255 로 담는다. (표에 없음과 가르려고, 보이지 않는 것은 같다)
Set a line color per ID. (the contour and crease lines of the model with that ID in front take this color, IDs not in the table keep the set_color color)
- Like the post-process outline of Unreal Custom Stencil, the color is picked by the ID already in the line target. For highlighting chosen models or coloring each team differently.
- The table is a 128 x 128 lookup texture covering every line ID (1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID). There is no limit on how many IDs are set, and it is read once per pixel.
- A line where two IDs touch takes the color of the nearer ID (closer to the camera). The color is stored as 8-bit sRGB, and alpha 0 is stored as 1/255. (to tell it apart from not being in the table; it is equally invisible)
- line_idu32
- 1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID. (draw_mesh 와 draw_mesh_instanced 에 준 번호, 범위 밖이면 하지 않는다)1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID. (the ID given to draw_mesh and draw_mesh_instanced, does nothing when out of range)
- color[f64; 4]
- [r, g, b, a] 의 sRGB 0 ~ 1.sRGB [r, g, b, a] in 0 ~ 1.
짝Counterpart: vanilla.js ToonScreenOutline.setLineColor
use vanilla::{create_octahedron_geometry, Matrix4, MeshBuilder, ToonDrawOptions, ToonInstance, ToonLineDrawOptions, ToonPartOptions, ToonRenderer, ToonScreenOutline, Vector3};
fn draw_picked_rock(gl: &vanilla::GlContext) -> Result<(), String> {
let mut renderer = ToonRenderer::new(gl)?;
let mut outline = ToonScreenOutline::new(gl)?;
let mut builder = MeshBuilder::new();
builder.add_part(&create_octahedron_geometry(0.3), &Matrix4::create_identity(), "#a89880", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
let rock_mesh = renderer.create_mesh(gl, &builder.read_arrays()).ok_or("mesh failed")?;
let instance_list: Vec<ToonInstance> = (0..3).map(|index| ToonInstance { model_matrix: Matrix4::create_translation(index as f64 * 0.7, 0.0, 0.0), line_id: Some(10 + index), ..ToonInstance::default() }).collect();
outline.set_line_color(11, [1.0, 0.85, 0.2, 1.0]);
let view_matrix = Matrix4::create_look_at(Vector3::create(0.7, 2.0, 3.0), Vector3::create(0.7, 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);
if outline.begin_line_ids(gl, &view_matrix, &projection_matrix) {
outline.draw_mesh_instanced(gl, &rock_mesh, &instance_list, 10, ToonLineDrawOptions::default());
outline.end_line_ids(gl);
}
renderer.begin_frame_with_matrices(gl, &view_matrix, &projection_matrix);
renderer.draw_mesh_instanced(gl, &rock_mesh, &instance_list, ToonDrawOptions::default());
renderer.end_frame(gl);
outline.draw_outline(gl);
Ok(())
}번호 하나를 색 표에서 빼기. (그 번호의 선은 set_color 의 색으로 돌아간다)
Remove one ID from the color table. (the lines of that ID go back to the set_color color)
- line_idu32
- set_line_color 에 준 번호.The ID given to set_line_color.
짝Counterpart: vanilla.js ToonScreenOutline.removeLineColor
색 표 비우기. (모든 선이 set_color 의 색으로 돌아간다)
Clear the color table. (all lines go back to the set_color color)
짝Counterpart: vanilla.js ToonScreenOutline.clearLineColors
use vanilla::ToonScreenOutline;
fn mark_lines(outline: &mut ToonScreenOutline) -> u32 {
outline.clear_line_colors();
outline.set_line_color(3, [1.0, 1.0, 1.0, 1.0]);
outline.set_line_color(7, [1.0, 0.3, 0.2, 1.0]);
outline.get_line_color_count()
}색 표에 든 번호 수 반환.
Return the number of IDs in the color table.
반환Returnsu32 set_line_color 로 넣고 빼지 않은 번호 수.The number of IDs set with set_line_color and not removed.
짝Counterpart: vanilla.js ToonScreenOutline.getLineColorCount
바깥 선 굵기 설정. (실루엣과 다른 번호와 맞닿은 곳의 선, 반지름이 아니라 선 하나의 굵기, 0 이면 긋지 않음, 꺾임 선 굵기도 이 단위로 센다)
Sets the outer line width. (lines at silhouettes and where different IDs meet, the width of one line rather than a radius, not drawn at 0, the crease line width is also counted in this unit)
- widthf64
- 선 하나의 굵기. (경계를 가운데로 양쪽에 반씩)Thickness of one line. (Half on each side of the boundary)
- unitToonOutlineWidthUnit
- 굵기의 단위. (원본 기본 Pixel)Unit of the thickness. (default Pixel in the original)
짝Counterpart: vanilla.js ToonScreenOutline.setWidth
꺾임 선 설정. (같은 번호 안에서 이웃한 면이 이 각(도)보다 더 꺾이면 선, 굵기는 set_width 의 단위, 진하기 0 ~ 1, 180 도나 굵기 0 이면 긋지 않음)
Sets crease lines. (a line where adjacent faces within the same ID bend more than this angle (degrees), the width is in the unit of set_width, strength 0 ~ 1, not drawn at 180 degrees or width 0)
- angle_degreesf64
- 꺾임 각. (180 이면 꺾임 선을 긋지 않는다)Crease angle. (180 draws no crease lines)
- widthf64
- 꺾임 선 하나의 굵기. (원본 기본 1, 0 이면 긋지 않는다)Thickness of one crease line. (default 1 in the original, 0 draws none)
- opacityf64
- 꺾임 선의 진하기. (원본 기본 1, 선 색의 알파에 곱한다)Opacity of the crease line. (default 1 in the original, multiplied into the alpha of the line color)
짝Counterpart: vanilla.js ToonScreenOutline.setCrease
초점 거리 설정. (원근 카메라에서 월드 굵기를 픽셀로 셀 거리, 보통 카메라에서 보는 점까지, 0 이면 그린 모형들의 평균 거리)
Sets the focal distance. (Distance at which world width is converted to pixels for a perspective camera, usually from the camera to the look-at point, 0 uses the average distance of the drawn models)
- focus_distancef64
- 카메라에서의 거리. (월드 길이)Distance from the camera. (World length)
짝Counterpart: vanilla.js ToonScreenOutline.setFocusDistance
깊이 문턱 설정. (같은 번호의 이웃 화소 가운데 가린 쪽이 가려진 쪽의 접평면에서 이만큼 넘게 떨어지면 가려진 실루엣으로 긋는다, 월드 길이)
depth_threshold는 면에 수직인 거리이고, 화소 여유가 더해진다. (set_depth_margin 의 배율 x 잰 오차, 오차는 화소 크기와 면의 기울기를 따른다)- 장면의 크기에 맞춘다. (사람 크기 장면이면 0.02 ~ 0.1, 0 이면 오차 여유만으로 가른다)
Set the depth threshold. (Among neighboring pixels with the same ID, if the occluding one is farther than this from the tangent plane of the occluded one, an occluded silhouette is drawn; world length)
depth_thresholdis the distance perpendicular to the face, and a pixel margin is added to it. (the scale of set_depth_margin x the measured error; the error follows the pixel size and the slope of the face)- Fit it to the scale of the scene. (0.02 ~ 0.1 for a human-sized scene; with 0 only the error margin decides)
- depth_thresholdf64
- 접평면 거리 문턱. (월드 길이, 면에 수직, 0 이상)Tangent plane distance threshold. (world length, perpendicular to the face, 0 or more)
짝Counterpart: vanilla.js ToonScreenOutline.setDepthThreshold
use vanilla::{GlContext, ToonScreenOutline};
fn make_outline(gl: &GlContext) -> Result<ToonScreenOutline, String> {
let mut outline = ToonScreenOutline::new(gl)?;
outline.set_depth_threshold(0.01);
assert_eq!(outline.depth_threshold(), 0.01);
Ok(outline)
}깊이 문턱 읽기. (월드 길이, 면에 수직)
Read the depth threshold. (world length, perpendicular to the face)
반환Returnsf64 접평면 거리 문턱. (기본 0.05)Tangent plane distance threshold. (default 0.05)
깊이 여유 배율 설정. (깊이 문턱에 더하는 화소 여유가 잰 오차의 몇 배인지, 기본 2)
- 이어진 면에서도 생기는 접평면 거리의 오차를 화소마다 잰다. 노멀 8 비트 팔면체의 각 오차(0.0165 rad) x 두 화소 자리 사이 거리(면이 비스듬할수록 길다), 꺾인 줄을 사이에 둔 두 화소의 화소 한 칸 x 두 노멀이 벌어진 사인, 깊이 24 비트 한 칸.
- 두 면이 나란한 낮은 턱은 꺾임 몫이 0 이라 화소 한 칸보다 낮아도 잡힌다. 둥근 면을 굵은 다각형으로 지어 보간 노멀이 면에서 크게 벗어나는 모형에서 깊이 문턱을 아주 낮추면 잔선이 생기니, 그때 배율을 올린다.
- 0 이면 깊이 문턱만으로 가른다.
Set the depth margin scale. (How many times the measured error is added to the depth threshold as a pixel margin, default 2)
- The error of the tangent plane distance that arises even on a continuous face is measured per pixel: the angle error of the 8-bit octahedral normal (0.0165 rad) x the distance between the two pixel positions (longer the more slanted the face), one pixel x the sine of the angle between the two normals for two pixels on either side of a crease, and one 24-bit depth step.
- A low ledge whose two faces are parallel has a crease share of 0, so it is caught even when it is lower than one pixel. If you lower the depth threshold a lot on a model built from coarse polygons whose interpolated normals stray far from the face, stray lines appear; raise the scale then.
- With 0 only the depth threshold decides.
- depth_marginf64
- 잰 오차에 곱할 배율. (0 이상, 0 밑은 0)Scale to multiply the measured error by. (0 or more, below 0 becomes 0)
짝Counterpart: vanilla.js ToonScreenOutline.setDepthMargin
use vanilla::{GlContext, ToonScreenOutline};
fn make_outline(gl: &GlContext) -> Result<ToonScreenOutline, String> {
let mut outline = ToonScreenOutline::new(gl)?;
outline.set_depth_threshold(0.02);
outline.set_depth_margin(1.0);
assert_eq!(outline.depth_margin(), 1.0);
Ok(outline)
}깊이 여유 배율 읽기.
Read the depth margin scale.
반환Returnsf64 잰 오차에 곱할 배율. (기본 2)Scale to multiply the measured error by. (default 2)
선의 판 해상도 몫 설정. (그리는 영역에 대한 몫 0.25 ~ 1, 기본 1, 폰과 태블릿의 가벼운 길은 낮춘다)
- 이름대로 섞기 앞의 모든 판(선의 판 = 노멀과 번호와 깊이, 가면, 씨앗, 넓히기 판)을 그리는 영역 x 몫 크기로 잡는다. 선의 판은 몫만큼 작은 해상도로 한 번 더 그려지므로 값이 몫의 제곱으로 준다. 기본 1 은 그리는 영역과 같은 크기라 화면이 바이트까지 그대로다.
- 몫이 1 보다 작을 때 가는 선(굵기 x 몫이 약 3.24 선의 판 픽셀 이하)은 선의 판 해상도에서 덮는 몫(진하기와 번호 색을 곱한 RGBA8)을 한 번 셈하고, 마지막 섞기가 그것을 쌍선형으로 한 번 읽는다. (읽기 9 에서 1) 굵은 선은 선의 판 해상도에서 점프 플러딩을 하고 섞을 때 거리를 그리는 영역 픽셀로 곱해 잰다. 어느 길이든 선 굵기는 그리는 영역 픽셀(set_width)이고 선 자리는 몫이 작을수록 가장자리가 부드러워진다.
- get_line_target() 의 line_texture, depth_texture 해상도는 그리는 영역 x 몫이다. (굵기 0 이면 선의 판만 그리는 동작은 그대로, 해상도만 그리는 영역과 다를 수 있다)
- CSS 화소당 1.5 화소로 맞추려면 몫 = 1.5 / (그리는 버퍼 화소 / CSS 화소) 로 준다.
Sets the line buffer resolution fraction. (fraction of the drawing area 0.25 to 1, default 1, phones and tablets lower it for a light path)
- As the name says, every buffer before the blend (line buffer = normal, id and depth, mask, seed, widening buffers) is sized to the drawing area x the fraction. The line buffer is drawn once more at the smaller resolution, so the cost drops with the square of the fraction. The default 1 is the same size as the drawing area, so the picture is byte for byte the same.
- Below 1, a thin line (width x fraction at most about 3.24 line buffer pixels) works out the coverage (RGBA8 multiplied by intensity and id color) once at the line buffer resolution, and the last blend reads it bilinearly once. (9 reads become 1) A thick line runs the jump flooding at the line buffer resolution and measures the distance in drawing area pixels when blending. On either path the line width is in drawing area pixels (set_width) and the smaller the fraction, the softer the edges.
- The line_texture and depth_texture resolution of get_line_target() is the drawing area x the fraction. (with width 0 drawing only the line buffer is unchanged, only the resolution can differ from the drawing area)
- To match 1.5 pixels per CSS pixel, give fraction = 1.5 / (drawing buffer pixels / CSS pixels).
- resolution_scalef64
- 0.25 ~ 1. (1 이면 그리는 영역 해상도 그대로)0.25 to 1. (1 is the drawing area resolution as it is)
짝Counterpart: vanilla.js ToonScreenOutline.setResolutionScale
HDR 출력 설정. (true 면 선 색을 선형으로 바꿔 섞는다, ToonRenderer::set_hdr_output 과 맞춘다)
Sets HDR output. (true converts the line color to linear before blending, match with ToonRenderer::set_hdr_output)
- is_hdr_outputbool
- true 면 선 색을 선형으로 바꿔 섞는다.If true, the line color is converted to linear before blending.
짝Counterpart: vanilla.js ToonScreenOutline.setHdrOutput
이번 프레임의 선 굵기. ([바깥 선, 꺾임 선] 의 그리는 영역 픽셀, end_line_ids 뒤에 정해짐, 긋지 않으면 0)
This frame's line widths. (drawing area pixels for [outer line, crease line], determined after end_line_ids, 0 if not drawn)
반환Returns[f64; 2] [바깥 선 굵기, 꺾임 선 굵기]. (긋지 않으면 0)[silhouette line thickness, crease line thickness]. (0 if not drawn)
짝Counterpart: vanilla.js ToonScreenOutline.getLineWidths
선의 판 반환. (없으면 None, 번호와 깊이와 가면 텍스처, 크기)
Returns the line buffer. (None when absent, the id, depth and mask textures, the size)
반환ReturnsOption<&ToonLineTarget> 선의 판. (노멀과 번호 텍스처, 깊이 텍스처, 가는 선의 씨앗 쪽 판, 굵은 선을 그었으면 씨앗과 넓히기 판 둘과 마친 쪽, 줄여 가는 선을 그었으면 덮는 몫 판, 이번 프레임의 길, 크기, 아직 짓지 않았거나 짓지 못했으면 None)Line buffer. (normal and id texture, depth texture, thin line side buffer, the seed and two widening buffers with the finished side when a thick line was drawn, the coverage buffer when a reduced thin line was drawn, the path of this frame, the size, None when not built yet or building failed)
짝Counterpart: vanilla.js ToonScreenOutline.getLineTarget
선 굵기 셈. ([바깥 선, 꺾임 선] 의 그리는 영역 픽셀, 번호를 그리는 프레임이 없으면 지금 값)
Computes the line widths. (drawing area pixels for [outer line, crease line], the current value if there is no frame drawing IDs)
반환Returns[f64; 2] [바깥 선 굵기, 꺾임 선 굵기].[silhouette line thickness, crease line thickness].
짝Counterpart: vanilla.js ToonScreenOutline.readLineWidths
pub fn begin_line_ids(&mut self, gl: &GlContext, view_matrix: &Matrix4, projection_matrix: &Matrix4) -> bool#번호 그리기 시작. (지금 뷰포트를 그리는 영역으로 적고, 선의 판을 묶어 비운다, 판을 짓지 못하면 false)
Begins drawing IDs. (records the current viewport as the drawing area, binds and clears the line target, false if the target cannot be built)
- gl&GlContext
- GL 컨텍스트.GL context.
- view_matrix&Matrix4
- 보기 행렬.View matrix.
- projection_matrix&Matrix4
- 투영 행렬. (원근이나 직교)Projection matrix. (Perspective or orthographic)
반환Returnsbool 선의 판을 짓지 못했으면 false. (그때 draw_mesh 는 아무것도 하지 않는다)false if the line target could not be built. (draw_mesh then does nothing)
짝Counterpart: vanilla.js ToonScreenOutline.beginLineIds
pub fn draw_mesh(&mut self, gl: &GlContext, mesh: &ToonMesh, model_matrix: &Matrix4, line_id: u32, options: ToonLineDrawOptions)#모형 하나의 번호 그리기. (ToonRenderer::draw_mesh 와 같은 행렬과 자세, 번호 1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID, 같은 번호끼리 맞닿은 곳은 긋지 않음, 화면 밖이면 건너뛴다)
Draws IDs for one model. (same matrices and pose as ToonRenderer::draw_mesh, IDs 1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID, no line where the same IDs meet, skipped if off-screen)
- gl&GlContext
- GL 컨텍스트.GL context.
- mesh&ToonMesh
- ToonRenderer::create_mesh 의 결과.Result of ToonRenderer::create_mesh.
- model_matrix&Matrix4
- 모형 행렬.Model matrix.
- line_idu32
- 1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID. (0 은 빈 곳이라 쓰지 않는다, 같은 번호끼리 맞닿은 곳은 긋지 않는다)1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID. (0 is empty space and not used, no line where the same IDs touch)
- optionsToonLineDrawOptions
- 그리기 꼴. (본 행렬, 거르기, 몸 번호 버퍼의 일부, 감기 뒤집기, 바깥 선과 꺾임 선을 낼지)Draw options. (joint matrices, culling, part of the body index buffer, flipped winding, whether to produce silhouette and crease lines)
짝Counterpart: vanilla.js ToonScreenOutline.drawMesh
pub fn draw_mesh_instanced(&mut self, gl: &GlContext, mesh: &ToonMesh, instance_list: &[ToonInstance], line_id: u32, options: ToonLineDrawOptions)#같은 모형 여럿의 번호를 한 번에 그리기. (인스턴스에 line_id 가 있으면 그 번호, 없으면 공통 번호, 꼴은 모든 인스턴스에 같다)
Draws IDs for multiple instances of the same model at once. (uses the instance's line_id if present, otherwise the common ID, the options are the same for all instances)
- gl&GlContext
- GL 컨텍스트.GL context.
- mesh&ToonMesh
- ToonRenderer::create_mesh 의 결과.Result of ToonRenderer::create_mesh.
- instance_list&[ToonInstance]
- 인스턴스 목록. (모형 행렬과 번호, 번호가 None 이면 공통 번호)Instance list. (model matrix and ID, the shared ID if the ID is None)
- line_idu32
- 공통 번호.Common ID.
- optionsToonLineDrawOptions
- draw_mesh 와 같다. (꼴은 모든 인스턴스에 같다, is_mirrored 가 None 이면 뒤집지 않는다)Same as draw_mesh. (the options are the same for every instance, None for is_mirrored does not flip)
짝Counterpart: vanilla.js ToonScreenOutline.drawMeshInstanced
pub fn draw_mesh_instance_buffer(&mut self, gl: &GlContext, mesh: &ToonMesh, instance_buffer: &ToonInstanceBuffer, instance_count: usize, line_id: u32, options: ToonLineDrawOptions)#영구 인스턴스 버퍼로 번호 그리기. (몸과 같은 GPU 버퍼를 쓰고 다시 올리지 않는다, 버퍼 전체의 경계로 통째 거른다, 원본 drawMeshInstanceBuffer)
- 인스턴스마다 번호는 꼴의 instanceLineId 칸, 없으면 공통 번호. 꼴에 행렬이 없으면 자리를 몰라 그리지 않는다. (정점 조각은 선의 판에서 돌지 않는다)
Draw ids with a persistent instance buffer. (uses the same GPU buffer as the body and does not upload again, culls the whole buffer by its bounds; the original drawMeshInstanceBuffer)
- The id of each instance is the instanceLineId slot of the layout, otherwise the common id. When the layout has no matrix the position is unknown and nothing is drawn. (vertex chunks do not run in the line board)
- gl&GlContext
- GL 컨텍스트.GL context.
- mesh&ToonMesh
- ToonRenderer::create_mesh 의 결과.Result of ToonRenderer::create_mesh.
- instance_buffer&ToonInstanceBuffer
- ToonRenderer::create_instance_buffer 의 결과. (몸과 같은 모형과 버퍼의 버텍스 어레이를 같이 쓴다)The result of ToonRenderer::create_instance_buffer. (shares the mesh and the vertex arrays of the buffer with the body)
- instance_countusize
- 그릴 인스턴스 수. (버퍼에 든 수를 넘으면 자른다)Number of instances to draw. (Clamped if more than the buffer holds)
- line_idu32
- 공통 번호. (꼴에 instanceLineId 가 없을 때)Common id. (when the layout has no instanceLineId)
- optionsToonLineDrawOptions
- draw_mesh 와 같다. (꼴은 모든 인스턴스에 같다, is_mirrored 가 None 이면 뒤집지 않는다)Same as draw_mesh. (the options are the same for every instance, None for is_mirrored does not flip)
짝Counterpart: vanilla.js ToonScreenOutline.drawMeshInstanceBuffer
use vanilla::{create_octahedron_geometry, Matrix4, MeshBuilder, ToonBufferUsage, ToonDrawOptions, ToonLineDrawOptions, ToonPartOptions, ToonRenderer, ToonScreenOutline, Vector3};
fn draw_rocks(gl: &vanilla::GlContext) -> Result<(), String> {
let mut renderer = ToonRenderer::new(gl)?;
let mut outline = ToonScreenOutline::new(gl)?;
let mut builder = MeshBuilder::new();
builder.add_part(&create_octahedron_geometry(0.3), &Matrix4::create_identity(), "#a89880", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
let rock_mesh = renderer.create_mesh(gl, &builder.read_arrays()).ok_or("mesh failed")?;
let instance_layout = renderer.create_instance_layout(&[("instanceMatrix", 16), ("instanceTint", 4), ("instanceLineId", 1)])?;
let mut data: Vec<f32> = Vec::new();
for index in 0..3 {
data.extend_from_slice(Matrix4::create_translation(index as f64 * 0.5, 0.0, 0.0).get_elements());
data.extend_from_slice(&[1.0, 1.0, 1.0, 1.0, 10.0 + index as f32]);
}
let instance_buffer = renderer.create_instance_buffer(gl, &instance_layout, &data, ToonBufferUsage::Static)?;
let view_matrix = Matrix4::create_look_at(Vector3::create(0.5, 2.0, 3.0), Vector3::create(0.5, 0.0, 0.0), Vector3::create(0.0, 1.0, 0.0));
let projection_matrix = Matrix4::create_perspective(std::f64::consts::PI / 4.0, 1.0, 0.1, 100.0);
if outline.begin_line_ids(gl, &view_matrix, &projection_matrix) {
outline.draw_mesh_instance_buffer(gl, &rock_mesh, &instance_buffer, 3, 10, ToonLineDrawOptions::default());
outline.end_line_ids(gl);
}
renderer.begin_frame_with_matrices(gl, &view_matrix, &projection_matrix);
renderer.draw_mesh_instance_buffer(gl, &rock_mesh, &instance_buffer, 3, ToonDrawOptions::default());
renderer.end_frame(gl);
outline.draw_outline(gl);
Ok(())
}번호 그리기 끝. (가는 선은 씨앗 쪽 판 하나를 고르고, 굵은 선은 씨앗을 고르고 점프 플러딩으로 넓힌 뒤, 프레임버퍼와 뷰포트와 상태를 돌린다)
- 가는 선(굵기가 약 3.24 선의 판 픽셀 이하): 화면 전체 패스가 씨앗 쪽 판 하나다. 섞기가 둘레 3 x 3 화소의 씨앗을 본다. (씨앗, 모으기, 넓히기 없음)
- 굵은 선: 씨앗, 모으기, 넓히기 걸음마다 한 패스. (씨앗 판과 넓히기 판은 처음 굵은 선을 그을 때 짓는다)
- 판을 통째로 덮어쓰는 패스는 앞에 판 비우기(clear_buffer_u32_slice, clear_buffer_f32_slice)를 불러 옛 내용을 읽어 들이지 않게 한다. (타일 GPU 의 판 불러오기를 없앰, 원본과 같은 자리)
Ends id drawing. (a thin line picks one side buffer, a thick line picks the seeds and widens them by jump flooding, then the framebuffer, viewport and state are restored)
- Thin line (width at most about 3.24 line buffer pixels): the full-screen pass is one side buffer. The blend looks at the seeds of the 3 x 3 pixels around. (no seed, gather or widening)
- Thick line: one pass per seed, gather and widening step. (the seed buffer and widening buffers are built the first time a thick line is drawn)
- A pass that overwrites a whole buffer first clears the buffer (clear_buffer_u32_slice, clear_buffer_f32_slice) so the old contents are not loaded. (removes the buffer load of tile GPUs, at the same place as the original)
- gl&GlContext
- GL 컨텍스트.GL context.
짝Counterpart: vanilla.js ToonScreenOutline.endLineIds
바깥선 긋기. (가는 선은 씨앗 쪽 판, 굵은 선은 넓힌 씨앗 판으로 begin_line_ids 때의 그리는 영역에 섞는다, 깊이는 보지도 쓰지도 않는다, 스텐실은 그대로)
Draws the outline. (a thin line blends from the side buffer and a thick line from the widened seed buffer into the drawing area of begin_line_ids, depth is neither read nor written, stencil is left as it is)
- gl&GlContext
- GL 컨텍스트.GL context.
짝Counterpart: vanilla.js ToonScreenOutline.drawOutline
다 쓴 뒤 지우기. (선의 판, 버텍스 어레이, 프로그램 아홉)
Deletes after use. (the line buffer, vertex array, nine programs)
- gl&GlContext
- GL 컨텍스트.GL context.
짝Counterpart: vanilla.js ToonScreenOutline.destroy
ToonScreenOutlineOptionsstruct traits Clone, Copy, Debug, PartialEq, Eq, Default
화면 공간 바깥선을 지을 때의 꼴. (원본 생성 options)
Options for building a screen-space outline. (original constructor options)
use vanilla::{ColorSpace, ToonScreenOutline, ToonScreenOutlineOptions};
fn create_linear_outline(gl: &vanilla::GlContext) -> Result<ToonScreenOutline, String> {
ToonScreenOutline::new_with_options(gl, ToonScreenOutlineOptions { color_space: ColorSpace::Linear })
}색 공간. (원본 colorSpace, 기본은 엔진의 색 공간, ToonRenderer 와 같은 값)
Color space. (original colorSpace, default is the engine's color space, the same value as the ToonRenderer)
반환ReturnsColorSpace
함수Functions
점프 플러딩의 걸음 목록. (씨앗을 reach 화소까지 넓히는 데 드는 걸음, 큰 것부터 반씩 줄여 1 까지)
- 걸음 k, k/2, ..., 1 은 씨앗을 2k - 1 화소까지 옮긴다. (Rong, Tan 2006)
Jump flooding step list. (the steps needed to expand seeds out to reach pixels, halving from the largest down to 1)
- Steps k, k/2, ..., 1 move seeds up to 2k - 1 pixels. (Rong, Tan 2006)
- reachf64
- 씨앗을 옮길 거리. (선의 판 픽셀)Distance to carry the seeds. (Line target pixels)
반환ReturnsVec<i32> 큰 것부터 1 까지의 걸음.Steps from the largest down to 1.
짝Counterpart: vanilla.js readJumpFloodSteps
use vanilla::read_jump_flood_steps;
assert_eq!(read_jump_flood_steps(4.0), vec![4, 2, 1]);상수Constants
선 번호의 상한. (선의 판에 14 비트로 쓴다, 0 은 빈 곳)
Upper limit of line IDs. (written to the line target with 14 bits, 0 is empty)
반환Returnsu32
짝Counterpart: vanilla.js TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID
ToonOutlineWidthUnitenum traits Clone, Copy, Debug, PartialEq, Eq
굵기의 단위.
Width unit.
| 이름Name | 설명Description |
|---|---|
World | 월드 길이. (직교는 투영의 세로 배율로, 원근은 초점 거리에서 화면 픽셀로 셈해 멀수록 가늘어진다)World length. (orthographic uses the projection's vertical scale, perspective converts to screen pixels at the focal distance, so it gets thinner farther away) |
Pixel | 그리는 영역의 픽셀. (거리와 상관없이 같은 굵기)Drawing area pixels. (the same width regardless of distance) |
ToonOutlinePathenum traits Clone, Copy, Debug, PartialEq, Eq
이번 프레임의 바깥선 길. (원본 outlinePath 의 "none", "thin", "thinScaled", "jumpFlood")
Outline path of this frame. ("none", "thin", "thinScaled", "jumpFlood" of outlinePath in the original)
use vanilla::{ToonOutlinePath, ToonScreenOutline};
fn is_thin_path(outline: &ToonScreenOutline) -> bool {
match outline.get_line_target() {
Some(line_target) => matches!(line_target.outline_path, ToonOutlinePath::Thin | ToonOutlinePath::ThinScaled),
None => false,
}
}| 이름Name | 설명Description |
|---|---|
None | 긋지 않음. (굵기가 둘 다 0 이라 선의 판만 남겼거나 아직 end_line_ids 전)Not drawn. (both widths are 0 so only the line buffer is kept, or before end_line_ids) |
Thin | 가는 선. (씨앗 쪽 판 하나와 섞기 하나, 굵기가 약 3.24 선의 판 픽셀 이하)Thin line. (one side buffer and one blend, width at most about 3.24 line buffer pixels) |
ThinScaled | 줄인 선의 판의 가는 선. (선의 판 해상도에서 덮는 몫 판 하나를 셈하고 쌍선형으로 한 번 읽어 섞는다)Thin line of a reduced line buffer. (works out one coverage buffer at the line buffer resolution and blends it with one bilinear read) |
JumpFlood | 굵은 선. (씨앗, 모으기, 넓히기 걸음, 섞기)Thick line. (seed, gather, widening steps, blend) |