vanilladocs
vanillapunch.com
API / graphics3d/toon/toondrawqueue

graphics3d/toon/toondrawqueue

툰 그리기 줄. (vanilla.js graphics3d/toon/toondrawqueue.js 의 ToonDrawQueue)

  • 한 프레임에 그릴 모형을 담아 두었다가 ToonRenderer 로 차례를 맞춰 그린다.
  • 차례: (화면 공간 바깥선의 선의 판) → 단계 BeforeOpaque → 불투명한 몸 → AfterOpaque → 불투명한 것의 바깥선 껍데기 → 화면 공간 바깥선 → AfterOutline → 비치는 것(카메라에서 먼 것부터, 깊이는 쓰지 않음) → AfterTransparent. 몸을 다 그린 뒤 바깥선을 몰아 그려 프로그램을 덜 바꾸고, 비치는 것은 뒤의 것이 비쳐 보이게 맨 끝에 먼 것부터 섞는다.
  • 비치는 것: 꼴의 alpha 나 tint_color 의 알파가 1 보다 작거나 blend_mode 가 Alpha 가 아닌 것. 바깥선도 함께(has_outline) 그린다.
  • 묶음: 꼴의 group 이 같은 비치는 것은 한 덩어리로 가운데 깊이(담긴 것의 평균)로 정렬하고 담은 차례로 그린다. is_depth_prepassed 가 묶음 안에 하나라도 있으면 그 덩어리는 깊이만 먼저 그린 뒤 같은 깊이(LEQUAL)인 화소에만 색을 칠한다. 여러 부품이 겹친 홀로그램이 두 겹으로 밝지 않고 한 덩어리로 비친다. 덩어리끼리는 먼 것부터라 서로 비친다.
  • 화면 공간 바깥선: set_screen_outline(ToonScreenOutline) 을 주면 draw 가 몸 앞에 불투명한 것을 선의 판에 그리고, 바깥선 껍데기 뒤에 섞는다. 번호는 꼴의 line_id (None 이면 담은 차례 + 1, 인스턴스는 ToonInstance 의 line_id, 인스턴스 버퍼는 꼴의 instanceLineId 칸이 먼저), 모형마다 has_screen_outline, has_crease_line 으로 끄고 켠다. 비치는 것은 선의 판에 그리지 않는다. 화면 사각형(ToonRenderer::set_screen_rect)이 있으면 그 사각형을 선의 판의 그리는 영역으로 쓴다. 러스트 판은 바깥선을 &'a mut 로 빌려 RefCell 에 담는다. (draw(&self) 에서 고쳐 쓴다)
  • 모서리 어둠: set_post_process(ToonPostProcess) 를 주고 후처리에서 set_ambient_occlusion 을 켜면 선의 판 뒤, 몸 앞에 셈해 렌더러에 걸고 end_frame 뒤에 푼다. (바깥선이 없으면 선 없이 선의 판만 그린다)
  • 단계 콜백: add_pass(stage, callback) 의 callback(gl, renderer) 를 그 자리에서 부른다. 부른 뒤 렌더러가 프레임의 그리기 상태를 다시 건다.
  • 인스턴스 묶음(add_mesh_instanced)은 불투명이면 몸과 바깥선을 한 번에 그리고, 비치면 인스턴스 자리의 가운데로 한 덩어리로 정렬한다. 인스턴스마다 걸러 그릴 때마다 올린다. (몸, 그림자, 선의 판이 같은 배열을 따로 올림) 오래 두는 것은 add_mesh_instance_buffer 로 한 번 올린 버퍼를 같이 쓴다.
  • 인스턴스 버퍼(add_mesh_instance_buffer)는 유니티 Graphics.RenderMeshInstanced 와 GraphicsBuffer, 고도 MultiMesh 꼴이다. 버퍼 전체의 경계로 통째 거르고 다시 올리지 않는다.
  • 그림자: draw_shadows(gl, renderer, shadow_map) 가 casts_shadow 가 true 인 불투명한 것만 그림자 깊이로 그린다. draw 보다 먼저 부른다. 점광과 스포트라이트 그림자는 draw_local_shadows(gl, renderer, shadow_atlas) 가 아틀라스의 칸마다 같은 것을 그린다. (렌더러에 set_local_shadows 로 건다) 그림자 판의 set_update_mode(ShadowUpdateMode) 를 따른다. 기본 OnChange 는 빛과 드리우개가 그대로면 다시 그리지 않고, 오래 그대로인 것은 구워 두고 움직이는 것만 덧그린다. (화면은 매 프레임 그린 것과 같다)
  • 사용: 매 프레임 clear() → add_mesh / add_mesh_instanced / add_mesh_instance_buffer / add_pass → (draw_shadows) → draw(gl, renderer, camera) 나 draw_with_matrices(gl, renderer, 보기 행렬, 투영 행렬) draw 는 renderer.begin_frame_with_camera 와 end_frame 을 스스로 부른다. draw_with_matrices 는 begin_frame_with_matrices 를 부른다. (직교 원 행렬 카메라) 화면 사각형(ToonRenderer::set_screen_rect)은 그 전에 건다. clear 는 담은 모형과 단계 콜백을 모두 비운다. (화면 공간 바깥선은 그대로 둔다)
  • 원본은 담은 것을 객체 참조로 든다. 러스트 판은 모형과 인스턴스 목록, 단계 콜백을 빌려 담으므로 줄이 그 수명 'a 를 갖는다. (프레임마다 새로 짓거나 clear 뒤 다시 담는다) 단계 콜백은 FnMut 이라 RefCell 에 담아 draw(&self) 에서 부른다.

Toon draw queue. (ToonDrawQueue of vanilla.js graphics3d/toon/toondrawqueue.js)

  • Holds the models to draw in a frame, then draws them in order with ToonRenderer.
  • Order: (line target of the screen-space outline) → stage BeforeOpaque → opaque bodies → AfterOpaque → outline shells of opaque things → screen-space outline → AfterOutline → transparent things (farthest from the camera first, depth not written) → AfterTransparent. Outlines are drawn together after all bodies to switch programs less, and transparent things are blended last from the farthest so what is behind shows through.
  • Transparent things: those whose options alpha or tint_color alpha is below 1, or whose blend_mode is not Alpha. Their outlines are drawn with them too (has_outline).
  • Groups: transparent things with the same options group are sorted as one lump by the middle depth (average of the members) and drawn in the order they were added. If even one member of a group has is_depth_prepassed, that lump draws depth first and then paints color only on pixels with the same depth (LEQUAL). A hologram made of several overlapping parts shows through as one lump instead of being doubly bright. Lumps are drawn farthest first so they show through each other.
  • Screen-space outline: if set_screen_outline(ToonScreenOutline) is given, draw draws opaque things into the line target before the bodies and blends it after the outline shells. The ID is the options line_id (the order added + 1 if None, for instances the line_id of ToonInstance, for instance buffers the instanceLineId slot of the layout comes first), and per model has_screen_outline and has_crease_line turn it off and on. Transparent things are not drawn into the line target. If there is a screen rectangle (ToonRenderer::set_screen_rect), that rectangle is used as the drawing area of the line target. The Rust version borrows the outline as &'a mut and keeps it in a RefCell. (Modified in draw(&self))
  • Ambient occlusion: give set_post_process(ToonPostProcess) and turn on set_ambient_occlusion in the post process, and it is computed after the line target and before bodies, set on the renderer and cleared after end_frame. (without outlines, only the line target is drawn, with no lines)
  • Stage callbacks: callback(gl, renderer) of add_pass(stage, callback) is called at that point. After the call, the renderer sets the frame's draw state again.
  • Instance batches (add_mesh_instanced) draw body and outline at once if opaque, and if transparent are sorted as one lump by the center of the instance positions. It uploads every time it culls and draws per instance. (the body, the shadow and the line board upload the same array separately) For long-lived instances, share a buffer uploaded once with add_mesh_instance_buffer.
  • An instance buffer (add_mesh_instance_buffer) is in the style of Unity Graphics.RenderMeshInstanced with GraphicsBuffer and Godot MultiMesh. It culls the whole buffer by its bounds and does not upload again.
  • Shadows: draw_shadows(gl, renderer, shadow_map) draws only opaque things whose casts_shadow is true into the shadow depth. Call it before draw. For point light and spotlight shadows, draw_local_shadows(gl, renderer, shadow_atlas) draws the same things per atlas tile. (Set on the renderer with set_local_shadows) Follows the shadow target's set_update_mode(ShadowUpdateMode). The default OnChange does not redraw when the lights and casters are unchanged, bakes casters that stay unchanged for a long time, and draws only the moving ones over them. (The screen is the same as drawing every frame)
  • Use: every frame clear() → add_mesh / add_mesh_instanced / add_mesh_instance_buffer / add_pass → (draw_shadows) → draw(gl, renderer, camera) or draw_with_matrices(gl, renderer, view matrix, projection matrix) draw calls renderer.begin_frame_with_camera and end_frame by itself. draw_with_matrices calls begin_frame_with_matrices. (Orthographic or raw matrix camera) The screen rectangle (ToonRenderer::set_screen_rect) is set before that. clear empties all added models and stage callbacks. (The screen-space outline is kept)
  • The original holds what is added as object references. The Rust version borrows the models, instance lists and stage callbacks, so the queue has their lifetime 'a. (Build a new one every frame, or add again after clear) Stage callbacks are FnMut, so they are kept in a RefCell and called in draw(&self).

ToonPassCallbacktype

소스source

단계 콜백. (gl, 렌더러)

Stage callback. (gl, renderer)

pub type ToonPassCallback<'a> = Box<dyn FnMut(&GlContext, &mut ToonRenderer) + 'a>

ToonDrawQueuestruct traits Default

짝Counterpart: vanilla.js ToonDrawQueue소스source

툰 그리기 줄. (머리말 참고)

Toon draw queue. (see the header comment)

예제Example모형마다 바깥선 꼴 정하기Decide the outline form per model
use vanilla::{create_box_geometry, create_faceted_chunk_geometry, Camera3D, Matrix4, MeshBuilder, ToonDrawOptions, ToonDrawQueue, ToonPartOptions, ToonRenderer, ToonScreenOutline, Vector3};

fn draw_scene(gl: &vanilla::GlContext) -> Result<(), String> {
	let mut renderer = ToonRenderer::new(gl)?;
	let mut floor_builder = MeshBuilder::new();
	floor_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, &floor_builder.read_arrays()).ok_or("floor mesh")?;
	let mut gem_builder = MeshBuilder::new();
	gem_builder.add_part(&create_faceted_chunk_geometry(0.5, &[1.0, 0.9, 1.1], [1.0, 1.0, 1.0]), &Matrix4::create_translation(0.0, 0.5, 0.0), "#a0c0ff", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
	let gem_mesh = renderer.create_mesh(gl, &gem_builder.read_arrays()).ok_or("gem mesh")?;
	let mut camera = Camera3D::new();
	camera.set_perspective(0.8, 0.1, 100.0);
	camera.look_at(Vector3::create(0.0, 2.0, 4.0), Vector3::create(0.0, 0.4, 0.0), Vector3::create(0.0, 1.0, 0.0));
	let mut screen_outline = ToonScreenOutline::new(gl)?;
	let mut queue = ToonDrawQueue::new();
	queue.set_screen_outline(Some(&mut screen_outline));
	queue.add_mesh(&floor_mesh, &Matrix4::create_identity(), ToonDrawOptions { line_id: Some(1), has_screen_outline: false, ..ToonDrawOptions::default() });
	queue.add_mesh(&gem_mesh, &Matrix4::create_identity(), ToonDrawOptions { line_id: Some(2), has_crease_line: false, ..ToonDrawOptions::default() });
	queue.draw(gl, &mut renderer, &camera);
	Ok(())
}
생성자constructorpub fn new() -> ToonDrawQueue<'a>#0.4.0 부터since 0.4.0소스source

생성.

Constructor.

반환ReturnsToonDrawQueue<'a> 빈 그리기 줄. (화면 공간 바깥선을 맡기지 않은 것)An empty draw queue. (With no screen-space outline handed over)

짝Counterpart: vanilla.js ToonDrawQueue.constructor

메서드methodpub fn clear(&mut self)#0.4.0 부터since 0.4.0소스source

비우기. (단계 콜백도 비운다, 화면 공간 바깥선은 그대로)

Clears. (stage callbacks are cleared too, the screen-space outline stays)

짝Counterpart: vanilla.js ToonDrawQueue.clear

메서드methodpub fn get_item_count(&self) -> usize#0.4.0 부터since 0.4.0소스source

담은 수 반환.

Returns the queued count.

반환Returnsusize 담은 모형과 인스턴스 묶음 수.Number of added models and instance batches.

짝Counterpart: vanilla.js ToonDrawQueue.getItemCount

메서드methodpub fn set_screen_outline(&mut self, screen_outline: Option<&'a mut ToonScreenOutline>)#0.4.0 부터since 0.4.0소스source

화면 공간 바깥선 맡기기. (draw 가 선의 판을 그리고 바깥선 껍데기 뒤에 섞는다, None 이면 맡기지 않음)

Hands over a screen-space outline. (draw renders the line target and blends it after the outline shells, None hands over nothing)

screen_outlineOption<&'a mut ToonScreenOutline>
ToonScreenOutline 이나 None. (줄의 수명 동안 빌린다)ToonScreenOutline or None. (Borrowed for the lifetime of the queue)

짝Counterpart: vanilla.js ToonDrawQueue.setScreenOutline

메서드methodpub fn has_screen_outline(&self) -> bool#0.4.0 부터since 0.4.0소스source

화면 공간 바깥선을 맡겼는지.

Whether a screen-space outline was handed over.

반환Returnsbool 맡겼으면 true.true if one is handed over.

메서드methodpub fn set_post_process(&mut self, post_process: Option<&'a mut ToonPostProcess>)#0.4.0 부터since 0.4.0소스source

툰 후처리 맡기기. (원본 setPostProcess, 모서리 어둠을 켰으면 draw 가 선의 판 뒤, 몸 앞에 셈해 렌더러에 걸고 end_frame 뒤에 푼다, None 이면 맡기지 않음)

  • 화면 공간 바깥선이 있으면 그 선의 판을, 없으면 후처리의 미리 그리기(get_ambient_occlusion_prepass)로 노멀과 깊이만 그린다.

Hands over the toon post process. (original setPostProcess; if ambient occlusion is on, draw computes it after the line target and before bodies, sets it on the renderer and clears it after end_frame, None hands over nothing)

  • With a screen-space outline it uses that line target; otherwise it draws only normals and depth with the post process prepass (get_ambient_occlusion_prepass).
post_processOption<&'a mut ToonPostProcess>
ToonPostProcess 나 None. (줄의 수명 동안 빌린다)ToonPostProcess or None. (borrowed for the lifetime of the queue)

짝Counterpart: vanilla.js ToonDrawQueue.setPostProcess

메서드methodpub fn has_post_process(&self) -> bool#0.4.0 부터since 0.4.0소스source

툰 후처리를 맡겼는지. (원본 getPostProcess 가 null 이 아닌지)

Whether a toon post process is handed over. (whether the original getPostProcess is not null)

반환Returnsbool 맡겼으면 true.true if one is handed over.

메서드methodpub fn add_pass(&mut self, stage: ToonDrawStage, callback: impl FnMut(&GlContext, &mut ToonRenderer) + 'a)#0.4.0 부터since 0.4.0소스source

단계 콜백 담기. (ToonDrawStage 의 자리에서 callback(gl, renderer) 를 부른다, 담은 차례로)

Adds a stage callback. (calls callback(gl, renderer) at the ToonDrawStage position, in the order added)

stageToonDrawStage
ToonDrawStage.
callbackimpl FnMut(&GlContext, &mut ToonRenderer) + 'a
(gl, renderer) 를 받는다. 부른 뒤 렌더러가 프레임의 그리기 상태를 다시 건다.Receives (gl, renderer). After the call, the renderer sets the frame's draw state again.

짝Counterpart: vanilla.js ToonDrawQueue.addPass

메서드methodpub fn add_mesh(&mut self, mesh: &'a ToonMesh, model_matrix: &Matrix4, options: ToonDrawOptions<'a>)#0.4.0 부터since 0.4.0소스source

모형 하나 담기.

Queues one model.

mesh&'a ToonMesh
ToonRenderer::create_mesh 의 결과.Result of ToonRenderer::create_mesh.
model_matrix&Matrix4
모형 행렬. (담을 때 베껴 둔다)Model matrix. (Copied when added)
optionsToonDrawOptions<'a>
ToonRenderer::draw_mesh 의 꼴. (casts_shadow, group, is_depth_prepassed, line_id, has_screen_outline, has_crease_line 도 이 줄이 본다)Draw options of ToonRenderer::draw_mesh. (This queue also reads casts_shadow, group, is_depth_prepassed, line_id, has_screen_outline, has_crease_line)

짝Counterpart: vanilla.js ToonDrawQueue.addMesh

메서드methodpub fn add_mesh_instanced(&mut self, mesh: &'a ToonMesh, instance_list: &'a [ToonInstance], options: ToonDrawOptions<'a>)#0.4.0 부터since 0.4.0소스source

같은 모형 여럿 담기. (GPU 인스턴싱, 비어 있으면 담지 않는다)

Queues multiple instances of the same model. (GPU instancing, not queued if empty)

mesh&'a ToonMesh
ToonRenderer::create_mesh 의 결과.Result of ToonRenderer::create_mesh.
instance_list&'a [ToonInstance]
ToonInstance 의 목록. (모형 행렬, 틴트 색, 선 번호)List of ToonInstance. (Model matrix, tint color, line ID)
optionsToonDrawOptions<'a>
add_mesh 와 같다.Same as add_mesh.

짝Counterpart: vanilla.js ToonDrawQueue.addMeshInstanced

메서드methodpub fn add_mesh_instance_buffer(&mut self, mesh: &'a ToonMesh, instance_buffer: &'a ToonInstanceBuffer, instance_count: usize, options: ToonDrawOptions<'a>)#0.4.0 부터since 0.4.0소스source

영구 인스턴스 버퍼로 같은 모형 여럿 담기. (몸, 바깥선 껍데기, 그림자, 선의 판이 한 GPU 버퍼를 같이 쓰고 다시 올리지 않는다, 원본 addMeshInstanceBuffer)

  • 버퍼는 ToonRenderer::create_instance_buffer 로 짓고 update_instance_buffer, update_instance_buffer_range 로 고친다. 버퍼 전체의 경계로 통째 거른다.
  • 인스턴스마다 선 번호는 꼴의 instanceLineId 칸, 없으면 options.line_id (None 이면 담은 차례 + 1).
  • 그림자 캐시(ShadowUpdateMode::OnChange)는 버퍼의 get_generation 으로 고친 것을 안다.

Queue several of the same mesh with a persistent instance buffer. (the body, the outline shell, the shadow and the line board share one GPU buffer and do not upload again; the original addMeshInstanceBuffer)

  • Create the buffer with ToonRenderer::create_instance_buffer and change it with update_instance_buffer or update_instance_buffer_range. The whole buffer is culled by its bounds.
  • The line id of each instance is the instanceLineId slot of the layout, otherwise options.line_id (None means queue order + 1).
  • The shadow cache (ShadowUpdateMode::OnChange) notices changes through get_generation of the buffer.
mesh&'a ToonMesh
ToonRenderer::create_mesh 의 결과.Result of ToonRenderer::create_mesh.
instance_buffer&'a ToonInstanceBuffer
ToonRenderer::create_instance_buffer 의 결과. (줄의 수명 동안 빌린다)The result of ToonRenderer::create_instance_buffer. (borrowed for the lifetime of the queue)
instance_countusize
그릴 인스턴스 수. (버퍼에 든 수를 넘으면 자른다, 0 이면 담지 않는다)Number of instances to draw. (clamped to the buffer, nothing is queued for 0)
optionsToonDrawOptions<'a>
add_mesh 와 같다.Same as add_mesh.

짝Counterpart: vanilla.js ToonDrawQueue.addMeshInstanceBuffer

예제Example광부의 바위 밭을 한 번 올린 버퍼로 그리고 하나만 고치기Draw the miner rock field from a buffer uploaded once and change just one
use vanilla::{create_octahedron_geometry, Camera3D, Matrix4, MeshBuilder, ToonBufferUsage, ToonDrawOptions, ToonDrawQueue, ToonPartOptions, ToonRenderer, ToonScreenOutline, Vector3};

fn draw_rocks(gl: &vanilla::GlContext) -> Result<(), String> {
	let mut renderer = ToonRenderer::new(gl)?;
	let mut builder = MeshBuilder::new();
	builder.add_part(&create_octahedron_geometry(0.3), &Matrix4::create_identity(), "#a89880", ToonPartOptions { has_outline: true, ..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 float_count = instance_layout.get_float_count();
	let mut data: Vec<f32> = Vec::new();
	for index in 0..25 {
		data.extend_from_slice(Matrix4::create_translation((index % 5) as f64 - 2.0, 0.0, (index / 5) as f64 - 2.0).get_elements());
		data.extend_from_slice(&[1.0, 1.0, 1.0, 1.0, 1.0 + index as f32]);
	}
	let instance_buffer = renderer.create_instance_buffer(gl, &instance_layout, &data, ToonBufferUsage::Dynamic)?;
	let mut camera = Camera3D::new();
	camera.set_perspective(0.8, 0.1, 50.0);
	camera.look_at(Vector3::create(0.0, 5.0, 6.0), Vector3::create(0.0, 0.0, 0.0), Vector3::create(0.0, 1.0, 0.0));
	let mut outline = ToonScreenOutline::new(gl)?;
	let mut queue = ToonDrawQueue::new();
	queue.set_screen_outline(Some(&mut outline));
	queue.add_mesh_instance_buffer(&rock_mesh, &instance_buffer, 25, ToonDrawOptions::default());
	queue.draw(gl, &mut renderer, &camera);
	let mut broken_rock = data[12 * float_count..13 * float_count].to_vec();
	broken_rock[16..20].copy_from_slice(&[0.5, 0.5, 0.5, 1.0]);
	renderer.update_instance_buffer_range(gl, &instance_buffer, 12, &broken_rock)?;
	queue.draw(gl, &mut renderer, &camera);
	Ok(())
}
메서드methodpub fn draw_shadows(&self, gl: &GlContext, renderer: &mut ToonRenderer, shadow_map: &ShadowMap)#0.4.0 부터since 0.4.0소스source

그림자 깊이 그리기. (불투명하고 casts_shadow 가 true 인 것만, 앞의 프레임버퍼와 뷰포트는 되돌린다)

  • shadow_map.set_update_mode 의 갱신 방식을 따른다. (기본 OnChange 는 빛과 드리우개가 그대로면 그리지 않는다)

Draws shadow depth. (only opaque ones whose casts_shadow is true, restores the previous framebuffer and viewport)

  • Follows the update mode of shadow_map.set_update_mode. (The default OnChange does not draw when the lights and casters are unchanged)
gl&GlContext
GL 컨텍스트.GL context.
renderer&mut ToonRenderer
ToonRenderer.
shadow_map&ShadowMap
ShadowMap.

짝Counterpart: vanilla.js ToonDrawQueue.drawShadows

메서드methodpub fn draw_local_shadows(&self, gl: &GlContext, renderer: &mut ToonRenderer, shadow_atlas: &ShadowAtlas)#0.4.0 부터since 0.4.0소스source

점광과 스포트라이트 그림자 깊이 그리기. (불투명하고 casts_shadow 가 true 인 것을 아틀라스의 칸마다, 앞의 프레임버퍼와 뷰포트는 되돌린다)

  • shadow_atlas.set_update_mode 의 갱신 방식을 따른다. (기본 OnChange 는 빛과 드리우개가 그대로면 그리지 않는다)

Draws point light and spotlight shadow depth. (Opaque ones with casts_shadow true, per atlas tile, the previous framebuffer and viewport are restored)

  • Follows the update mode of shadow_atlas.set_update_mode. (The default OnChange does not draw when the lights and casters are unchanged)
gl&GlContext
GL 컨텍스트.GL context.
renderer&mut ToonRenderer
ToonRenderer.
shadow_atlas&ShadowAtlas
ShadowAtlas. (update_lights 를 부른 것)ShadowAtlas. (One on which update_lights was called)

짝Counterpart: vanilla.js ToonDrawQueue.drawLocalShadows

메서드methodpub fn draw(&self, gl: &GlContext, renderer: &mut ToonRenderer, camera: &Camera3D)#0.4.0 부터since 0.4.0소스source

담은 것 그리기. (화면 공간 바깥선이 있으면 선의 판부터, begin_frame_with_camera 와 end_frame 을 스스로 부른다)

Draws the queued items. (starting with the line target if there is a screen-space outline, calls begin_frame_with_camera and end_frame itself)

gl&GlContext
GL 컨텍스트.GL context.
renderer&mut ToonRenderer
ToonRenderer.
camera&Camera3D
Camera3D.

짝Counterpart: vanilla.js ToonDrawQueue.draw

메서드methodpub fn draw_with_matrices(&self, gl: &GlContext, renderer: &mut ToonRenderer, view_matrix: &Matrix4, projection_matrix: &Matrix4)#0.4.0 부터since 0.4.0소스source

보기와 투영 행렬로 담은 것 그리기. (Camera3D 없이, begin_frame_with_matrices 와 end_frame 을 스스로 부른다)

Draws the queued items with view and projection matrices. (without Camera3D, calls begin_frame_with_matrices and end_frame itself)

gl&GlContext
GL 컨텍스트.GL context.
renderer&mut ToonRenderer
ToonRenderer.
view_matrix&Matrix4
보기 행렬.View matrix.
projection_matrix&Matrix4
투영 행렬.Projection matrix.

짝Counterpart: vanilla.js ToonDrawQueue.drawWithMatrices

ToonDrawStageenum traits Clone, Copy, Debug, PartialEq, Eq

짝Counterpart: vanilla.js ToonDrawStage소스source

그리기 줄의 단계. (add_pass 의 콜백을 부를 자리)

  • BeforeOpaque: 불투명한 몸 앞. (평면 거울에 비친 모습, 하늘)
  • AfterOpaque: 불투명한 몸 뒤, 바깥선 껍데기 앞.
  • AfterOutline: 바깥선 껍데기와 화면 공간 바깥선 뒤, 비치는 것 앞.
  • AfterTransparent: 비치는 것 뒤. (효과)

Stages of the draw queue. (positions where add_pass callbacks are called)

  • BeforeOpaque: before opaque bodies. (planar mirror reflections, sky)
  • AfterOpaque: after opaque bodies, before outline shells.
  • AfterOutline: after outline shells and the screen-space outline, before translucent ones.
  • AfterTransparent: after translucent ones. (effects)
이름Name설명Description
BeforeOpaque불투명한 몸 앞. (평면 거울에 비친 모습, 하늘)Before opaque bodies. (Planar mirror reflections, sky)
AfterOpaque불투명한 몸 뒤, 바깥선 껍데기 앞.After opaque bodies, before outline shells.
AfterOutline바깥선 껍데기와 화면 공간 바깥선 뒤, 비치는 것 앞.After outline shells and the screen-space outline, before transparent things.
AfterTransparent비치는 것 뒤. (효과)After transparent things. (Effects)