# graphics3d/toon/toonpostprocess (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/graphics3d/toon/toonpostprocess/

툰 HDR 마무리. (vanilla.js graphics3d/toon/toonpostprocess.js 의 ToonPostProcess)
- 실수 렌더 타겟에 그린 선형 색을 블룸, 노출, 톤매핑, 감마로 화면에 낸다.
- 엔진의 RenderTarget(반정밀 실수 색, 깊이), BloomEffect(또는 MultiLevelBloomEffect), FullscreenPass 를 엮는다.
- 사용: ToonRenderer::set_hdr_output(true) 뒤
  begin(gl, 바탕 선형 색) → ToonRenderer 로 그리기 → end(gl, 낼 프레임버퍼, 뷰포트)
  end 는 (멀티샘플이면 풀고) 블룸을 셈하고 톤매핑한 색을 낼 프레임버퍼(None 이면 화면)에 그린다. 2D 와 섞으려면 그 뒤 Graphic::restore_render_state.
- 생성 옵션: new_with_options(gl, 너비, 높이, ToonPostProcessOptions { sample_count, use_float_color, depth_bits, use_depth_texture, color_space }) (원본 생성자의 options, new 는 기본 옵션으로 지금과 같은 RGBA16F, 깊이 16, 멀티샘플 없음)
  sample_count 가 2 이상이면 씬을 멀티샘플(MSAA) 렌더버퍼에 그리고 end 앞에서 텍스처로 푼다. 기기가 받는 수로 줄인다. (get_sample_count, set_sample_count)
  depth_bits 24 는 깊이 24 비트. (먼 면이 먼 장면) use_depth_texture 는 씬 깊이를 텍스처로 남긴다. (set_lit_area 가 쓴다)
- 색 공간: 씬 렌더 타겟에는 선형 색을 쓴다. (ToonRenderer::set_hdr_output(true), ToonScreenOutline::set_hdr_output(true), ToonVfx 색도 선형으로 본다)
  감마를 건 색 g 를 실수 판에 쓰고 합성에서 g^2.2 로 되돌리던 게임은 그 값을 미리 선형으로 바꿔 넘긴다. 색은 c^2.2, 감마 쪽에서 곱하던 밝기 배 k 는 선형 k^2.2 다.
  (예: 1.37 은 선형 2, 1.6 은 2.81, 2.08 은 5, 밝기 1.6 에 배 1.6 이면 (1.6 x 1.6)^2.2 = 7.9) 블룸 문턱과 무릎은 선형 밝기다.
  이 예는 감마 쪽(감마를 건 색 g)에서 곱하던 배일 때만 맞다. 선형 색에 곱하던 배와 블룸 문턱, 무릎처럼 처음부터 선형인 값은 바꾸지 않고 그대로 넘긴다.
- 실수 판을 못 쓰는 기기: use_float_color(기본 true)여도 is_float_color_supported 가 false 면 RGBA8 판으로 짓는다. (get_use_float_color 가 false)
  그때와 use_float_color: false 는 LDR 길이다. 씬에는 화면 색(감마를 건 색, ToonRenderer::set_hdr_output(false))을 그리고, 합성은 톤매핑과 감마 없이 블룸을 더해 색 보정만 건다.
- 캔버스 antialias: 이 후처리가 자기 MSAA 판(sample_count)에 그리므로 쓰는 게임은 EngineConfiguration::antialias 를 false 로 짓는다.
  true 면 캔버스 자체가 MSAA 라 화면에 옮기는 패스와 UI 가 표본마다 섞여 값이 더 든다. (맥미니 2560x1440 툰 후처리 장면 GPU 처리량 6.89 → 6.49 ms, 끈 판 6.81 → 5.22 ms, 원본 같은 장면에서 잰 값)
  예: engine_configuration.antialias = false;
- 블룸: 기본은 반 해상도 9 탭 가우시안(BloomEffect, 문턱 0.9 ~ 1.6, 주고받는 판 RGBA8, set_bloom_float_color 로 RGBA16F).
  set_bloom_levels(gl, 단 수, 문턱, 무릎) 로 단 수를 1 이상 주면 MultiLevelBloomEffect(반씩 줄였다 천막 꼴로 키우며 더함, 씬과 같은 정밀도의 판)로 바꾼다. 0 이면 기본으로 돌린다. 세기는 set_bloom 이 둘 다에 쓴다.
- 톤매핑은 ACES 근사(Krzysztof Narkowicz 2016, 원문이 CC0 또는 MIT 로 쓰게 함)다. 노출(set_exposure)을 곱한 뒤 매핑하고 sRGB 감마를 건다.
- 색 보정: 감마를 건 뒤 밝기(set_brightness, 밝힌 자리 set_lit_area 안은 1 쪽으로), 채도, 색조(밝기 1 로 맞춘 색을 곱함), 안개빛(어두운 곳을 그 색 쪽으로), 대비, 가장자리 어둡게 차례로 건다. (set_color_grade, set_vignette)
  기본은 밝기 1, 채도 1, 대비 1, 색조 0, 안개빛 0, 가장자리 0 이라 보정이 없다.
- 해상도 배율: set_resolution_scale(gl, 배율) 이면 씬 판을 출력 크기 x 배율로 짓고 end 의 뷰포트로 키워(선형 거르기) 낸다. (3D 만 낮춰 그리고 UI 는 기기 화소 그대로 둘 때, 기본 1)
- 노드 사각형 안에 낼 때: resize(사각형 너비, 높이) → begin → 그리기(ToonRenderer 의 화면 사각형은 풀어 둔다) → end(None, [x, 드로잉 버퍼 높이 - y - 높이, 너비, 높이]).
- 색 공간: 톤매핑 뒤 화면 색의 곡선은 감마 색 공간(기본)은 pow(1 / 2.2), 선형 색 공간(options.color_space 나 엔진의 ColorSpace::Linear)은 sRGB 표준 곡선(IEC 61966-2-1)이다. (ToonRenderer 의 LDR 출력과 같은 곡선)
- 모서리 어둠(화면 공간 AO): set_ambient_occlusion(켬, 세기, 반지름, 해상도 배율, 직접 빛 몫) 로 켠다. (기본 꺼짐, 세기 0.5, 반지름 0.5 월드 길이, 반 해상도, 직접 빛 몫 0)
  반 해상도 GTAO(Jimenez 2016) → 가로 흐림 → 세로 흐림과 온 해상도로 키우기, 세 패스다. 흐림은 깊이와 노멀로 가장자리를 지킨다.
  노멀과 깊이는 화면 바깥선(ToonScreenOutline)의 선의 판을 다시 쓴다. 바깥선이 없는 장면은 선은 긋지 않고 선의 판만 그리는 get_ambient_occlusion_prepass() 를 쓴다.
  ToonDrawQueue::set_post_process(이것) 이면 줄이 선의 판 뒤, 몸 앞에 draw_ambient_occlusion 을 부르고 렌더러에 결과를 건다. 몸 셰이더는 바탕빛(하늘과 땅 빛)에 곱하고, 직접 빛 몫만큼 해, 채움빛, 점광의 확산과 반사광에도 곱한다. (칸을 고른 뒤라 칸 경계는 그대로, 몫 0 이면 바탕빛에만)
- 원본과 다른 점: GL 객체를 다시 짓는 설정(set_sample_count, set_resolution_scale, set_bloom_levels, set_bloom_float_color)은 gl 을 받고 Result 를 돌려준다.

## ToonPostProcessOptions (struct) (Clone, Copy, Debug, PartialEq, Eq, Default)

생성 옵션. (원본 생성자의 options, 기본값은 멀티샘플 없음 / 실수 판 / 깊이 16 / 깊이 텍스처 없음)

예제: 멀티샘플 넷에 깊이 24 비트 옵션

```rust
use vanilla::ToonPostProcessOptions;

let options = ToonPostProcessOptions { sample_count: 4, depth_bits: 24, ..ToonPostProcessOptions::default() };
assert!(options.use_float_color);
assert!(!options.use_depth_texture);
```

- `pub sample_count: i32` (field, since 0.4.0): 멀티샘플 표본 수. (2 밑이면 없음)
  - returns i32
- `pub use_float_color: bool` (field, since 0.4.0): 실수 판을 쓸지. (기기가 못 쓰면 false 로 짓는다)
  - returns bool
- `pub depth_bits: i32` (field, since 0.4.0): 깊이 렌더버퍼 비트 수. (16 이나 24)
  - returns i32
- `pub use_depth_texture: bool` (field, since 0.4.0): 씬 깊이를 텍스처로 남길지. (set_lit_area)
  - returns bool
- `pub color_space: ColorSpace` (field, since 0.4.0): 색 공간. (원본 colorSpace, 기본은 엔진의 색 공간, ToonRenderer 와 같은 값)
  - returns ColorSpace

## ToonPostProcess (struct)

툰 HDR 마무리. (머리말 참고)

예제: 툰 장면을 실수 판에 그리고 블룸과 톤매핑으로 내기

```rust
use vanilla::{create_sphere_geometry, Camera3D, Matrix4, MeshBuilder, ToonDrawOptions, ToonPartOptions, ToonPostProcess, ToonPostProcessOptions, ToonRenderer, Vector3};

fn draw_glowing_ball(gl: &vanilla::GlContext, width: i32, height: i32) -> Result<(), String> {
	let mut post_process = ToonPostProcess::new_with_options(gl, width, height, ToonPostProcessOptions { sample_count: 4, ..ToonPostProcessOptions::default() })?;
	post_process.set_exposure(1.2);
	post_process.set_bloom(true, 0.8, 0.9, 1.6);
	let mut renderer = ToonRenderer::new(gl)?;
	renderer.set_hdr_output(post_process.get_use_float_color());
	let mut builder = MeshBuilder::new();
	builder.add_part(&create_sphere_geometry(0.5, 32, 20, std::f64::consts::PI), &Matrix4::create_identity(), "#ffd080", ToonPartOptions { glow: 2.0, ..ToonPartOptions::default() });
	let mesh = renderer.create_mesh(gl, &builder.read_arrays()).ok_or("mesh failed")?;
	let mut camera = Camera3D::new();
	camera.set_perspective(0.8, 0.1, 100.0);
	camera.set_aspect_ratio(width as f64 / height as f64);
	camera.look_at(Vector3::create(0.0, 1.0, 3.0), Vector3::create(0.0, 0.0, 0.0), Vector3::create(0.0, 1.0, 0.0));
	post_process.begin(gl, [0.02, 0.02, 0.04]);
	renderer.begin_frame_with_camera(gl, &camera);
	renderer.draw_mesh(gl, &mesh, &Matrix4::create_identity(), ToonDrawOptions::default());
	renderer.end_frame(gl);
	post_process.end(gl, None, [0, 0, width, height]);
	Ok(())
}
```

- `pub fn new(gl: &GlContext, width: i32, height: i32) -> Result<ToonPostProcess, String>` (constructor, since 0.4.0): 생성. (화면 픽셀 크기, 기본 옵션)
  - `gl` &GlContext: 툰 렌더러와 같은 컨텍스트.
  - `width` i32: 출력 너비. (픽셀)
  - `height` i32: 출력 높이. (픽셀)
  - returns Result<ToonPostProcess, String>: 새 툰 HDR 마무리. 씬 렌더 타겟, 블룸, 합성 셰이더를 못 지으면 Err(오류 글).
- `pub fn new_with_options(gl: &GlContext, width: i32, height: i32, options: ToonPostProcessOptions) -> Result<ToonPostProcess, String>` (static, since 0.4.0): 옵션을 주어 생성. (원본 new ToonPostProcess(gl, 너비, 높이, options))
  - `gl` &GlContext: 툰 렌더러와 같은 컨텍스트.
  - `width` i32: 출력 너비. (픽셀)
  - `height` i32: 출력 높이. (픽셀)
  - `options` ToonPostProcessOptions: 생성 옵션. (멀티샘플 표본 수, 실수 판, 깊이 비트 16 이나 24, 깊이 텍스처, 색 공간)
  - returns Result<ToonPostProcess, String>: 새 툰 HDR 마무리. 씬 렌더 타겟, 블룸, 합성 셰이더를 못 지으면 Err(오류 글).
- `pub fn is_float_color_supported(gl: &GlContext) -> bool` (static, since 0.4.0): 실수 컬러 판을 그릴 수 있는지. (웹은 EXT_color_buffer_float 나 EXT_color_buffer_half_float 가 있어야, 1 x 1 RGBA16F 를 붙인 프레임버퍼가 완성되는지)
  - `gl` &GlContext: 알아볼 컨텍스트.
  - returns bool: RGBA16F 판에 그릴 수 있으면 true.
- `pub fn resize(&mut self, gl: &GlContext, width: i32, height: i32) -> Result<(), String>` (method, since 0.4.0): 크기 바꾸기. (출력 크기, 씬 판은 해상도 배율을 곱함, 같으면 그대로)
  - `gl` &GlContext: GL 컨텍스트.
  - `width` i32: 출력 너비. (픽셀)
  - `height` i32: 출력 높이. (픽셀)
  - returns Result<(), String>: 판을 맞췄으면 Ok. 다시 짓다 GL 객체를 못 만들면 Err(GL 의 오류 글).
- `pub fn set_resolution_scale(&mut self, gl: &GlContext, resolution_scale: f64) -> Result<(), String>` (method, since 0.4.0): 해상도 배율 설정. (씬 판 = 출력 크기 x 배율, 0.05 ~ 4, 기본 1)
  - `gl` &GlContext: GL 컨텍스트.
  - `resolution_scale` f64: 씬 판의 배율. (0.05 ~ 4)
  - returns Result<(), String>: 판을 맞췄으면 Ok. 다시 짓다 GL 객체를 못 만들면 Err(GL 의 오류 글).
- `pub fn get_resolution_scale(&self) -> f64` (method, since 0.4.0): 해상도 배율 반환.
  - returns f64: 씬 판의 배율.
- `pub fn set_sample_count(&mut self, gl: &GlContext, sample_count: i32) -> Result<(), String>` (method, since 0.4.0): 멀티샘플 표본 수 설정. (2 밑이면 없음, 바뀌면 씬 판을 다시 짓는다)
  - `gl` &GlContext: GL 컨텍스트.
  - `sample_count` i32: 멀티샘플 표본 수. (2 밑이면 멀티샘플 없음)
  - returns Result<(), String>: 같은 수거나 씬 판을 다시 지었으면 Ok. 새 판을 못 지으면 Err(GL 의 오류 글, 앞의 판은 그대로 둔다).
- `pub fn get_sample_count(&self) -> i32` (method, since 0.4.0): 실제로 쓰는 멀티샘플 표본 수 반환. (0 이면 없음)
  - returns i32: 씬 판이 실제로 쓰는 표본 수. (기기가 받는 수로 줄인 것, 0 이면 없음)
- `pub fn get_use_float_color(&self) -> bool` (method, since 0.4.0): 씬 판이 실수인지 반환. (false 면 LDR 길)
  - returns bool: 씬 판이 실수면 true. (ToonRenderer::set_hdr_output 에 그대로 넘긴다)
- `pub fn begin(&self, gl: &GlContext, clear_color: [f64; 3])` (method, since 0.4.0): 씬 그리기 시작. (씬 렌더 타겟을 묶고 바탕 색과 깊이로 비운다, HDR 길은 선형 색, LDR 길은 화면 색)
  - `gl` &GlContext: GL 컨텍스트.
  - `clear_color` [f64; 3]: [r, g, b] 바탕 색. (HDR 길은 선형 색, LDR 길은 화면 색)
- `pub fn end(&self, gl: &GlContext, output_framebuffer: Option<GlFramebuffer>, viewport: [i32; 4])` (method, since 0.4.0): 마무리. (멀티샘플이면 풂 → 블룸 → 톤매핑해 낼 프레임버퍼에, viewport 는 [x, y, 너비, 높이])
  - `gl` &GlContext: GL 컨텍스트.
  - `output_framebuffer` Option<GlFramebuffer>: 낼 프레임버퍼. (None 이면 화면)
  - `viewport` [i32; 4]: [x, y, 너비, 높이] 낼 자리. (드로잉 버퍼 픽셀, 왼쪽 아래가 원점)
- `pub fn set_exposure(&mut self, exposure: f64)` (method, since 0.4.0): 노출 설정. (톤매핑 전에 곱한다, 1 이 기본)
  - `exposure` f64: 노출 배. (0 이상, 1 이 기본)
- `pub fn set_bloom(&mut self, is_bloom_enabled: bool, bloom_strength: f64, threshold_start: f64, threshold_end: f64)` (method, since 0.4.0): 블룸 설정. (켜기, 세기, 밝은 곳을 뽑는 문턱의 시작과 끝, 문턱은 기본 9 탭 블룸에만 쓴다)
  - `is_bloom_enabled` bool: 블룸을 켤지.
  - `bloom_strength` f64: 블룸 세기. (씬 색에 더하는 배, 기본 0.6)
  - `threshold_start` f64: 밝은 곳을 뽑기 시작하는 선형 밝기. (기본 0.9)
  - `threshold_end` f64: 다 뽑는 선형 밝기. (기본 1.6)
- `pub fn set_bloom_levels(&mut self, gl: &GlContext, level_count: usize, threshold: f64, knee: f64) -> Result<(), String>` (method, since 0.4.0): 블룸 단 수 설정. (0 이면 기본 9 탭 블룸, 1 이상이면 그 단 수의 다단 블룸, 문턱과 무릎은 다단 블룸의 선형 밝기)
  - 다단 블룸 판은 씬 판과 같은 정밀도다. (HDR 길은 RGBA16F)
  - `gl` &GlContext: GL 컨텍스트.
  - `level_count` usize: 단 수. (0 이면 기본 9 탭 블룸으로 돌린다)
  - `threshold` f64: 다단 블룸의 문턱. (선형 밝기)
  - `knee` f64: 문턱 둘레를 부드럽게 넘기는 폭. (선형 밝기)
  - returns Result<(), String>: 바꿨으면 Ok. 다단 블룸의 셰이더나 판을 못 지으면 Err(오류 글).
- `pub fn get_bloom_level_count(&self) -> usize` (method, since 0.4.0): 블룸 단 수 반환. (0 이면 기본 9 탭 블룸)
  - returns usize: 다단 블룸의 단 수. (0 이면 기본 9 탭 블룸)
- `pub fn set_bloom_float_color(&mut self, gl: &GlContext, is_float_color: bool) -> Result<(), String>` (method, since 0.4.0): 기본 9 탭 블룸의 주고받는 판을 실수로. (true 면 RGBA16F, 기본 false 는 RGBA8, 씬 판이 실수가 아니면 무시)
  - `gl` &GlContext: GL 컨텍스트.
  - `is_float_color` bool: true 면 RGBA16F, false 면 RGBA8.
  - returns Result<(), String>: 바꿨거나 이미 같으면 Ok. 새 판을 못 지으면 Err(GL 의 오류 글, 앞의 판은 그대로 둔다).
- `pub fn set_brightness(&mut self, brightness: f64)` (method, since 0.4.0): 밝기 설정. (색 보정 맨 앞에서 곱한다, 1 이 그대로)
  - `brightness` f64: 밝기 배. (0 이상, 1 이 그대로)
- `pub fn set_lit_area(&mut self, center: [f64; 3], inner_radius: f64, outer_radius: f64, inverse_view_projection_matrix: &Matrix4)` (method, since 0.4.0): 밝힌 자리 설정. (그 자리에서 수평 거리 inner_radius 안은 밝기 1, outer_radius 밖은 set_brightness 의 밝기, 사이는 부드럽게)
  - 씬 깊이 텍스처(옵션 use_depth_texture)와 그 프레임의 보기와 투영의 역행렬로 화소마다 월드 자리를 되짚는다. 깊이 텍스처가 없으면 무시한다.
  - 카메라가 움직이면 프레임마다 다시 준다. 아무것도 그리지 않은 바탕은 먼 면의 자리로 셈한다.
  - `center` [f64; 3]: 밝힐 자리. ([x, y, z] 월드 자리, 수평 거리는 x 와 z 로 잰다)
  - `inner_radius` f64: 밝기 1 인 수평 반지름. (월드 길이)
  - `outer_radius` f64: 이 밖은 set_brightness 의 밝기인 수평 반지름. (월드 길이)
  - `inverse_view_projection_matrix` &Matrix4: 이번 프레임 보기와 투영의 역행렬.
- `pub fn clear_lit_area(&mut self)` (method, since 0.4.0): 밝힌 자리 풀기.
- `pub fn set_color_grade(&mut self, saturation: f64, contrast: f64, tone_color: [f64; 3], tone_amount: f64, haze_color: [f64; 3], haze_amount: f64)` (method, since 0.4.0): 색 보정 설정. (채도와 대비는 1 이 그대로, 색조와 안개빛은 sRGB [r, g, b] 0 ~ 1 과 섞는 양 0 ~ 1)
  - 색조 색은 밝기(Rec. 709)를 1 로 맞춰 곱하므로 밝기는 그대로 두고 빛깔만 물든다.
  - 안개빛은 어두운 곳일수록 그 색 쪽으로 끌어올린다. (양 x (1 - 밝기))
  - `saturation` f64: 채도. (1 이 그대로, 0 이면 흑백)
  - `contrast` f64: 대비. (1 이 그대로)
  - `tone_color` [f64; 3]: [r, g, b] 색조 색. (sRGB 0 ~ 1, 밝기를 1 로 맞춰 곱한다)
  - `tone_amount` f64: 색조를 섞는 양. (0 ~ 1)
  - `haze_color` [f64; 3]: [r, g, b] 안개빛 색. (sRGB 0 ~ 1)
  - `haze_amount` f64: 안개빛을 섞는 양. (0 ~ 1, 어두운 곳일수록 세다)
- `pub fn set_vignette(&mut self, vignette_strength: f64)` (method, since 0.4.0): 가장자리 어둡게 설정. (0 이 없음, 1 이면 구석이 까맣게)
  - `vignette_strength` f64: 가장자리를 어둡게 하는 세기. (0 이 없음, 1 이면 구석이 까맣게)
- `pub fn get_scene_render_target(&self) -> &RenderTarget` (method, since 0.4.0): 씬 렌더 타겟. (다른 후처리를 끼울 때)
  - returns &RenderTarget: 씬을 그리는 렌더 타겟. (해상도 배율이나 표본 수를 바꾸면 다시 지어질 수 있다)
- `pub fn destroy(&mut self, gl: &GlContext)` (method, since 0.4.0): 지우기.
  - `gl` &GlContext: GL 컨텍스트.
- `pub fn get_color_space(&self) -> ColorSpace` (method, since 0.4.0): 색 공간 반환. (원본 getColorSpace, 생성 때 정한 값, 톤매핑 뒤 화면 색을 내는 곡선을 가른다)
  - returns ColorSpace: ColorSpace::Gamma 나 ColorSpace::Linear.
- `pub fn set_ambient_occlusion(&mut self, is_enabled: bool, intensity: f64, radius: f64, resolution_scale: f64, direct_lighting_strength: f64)` (method, since 0.4.0): 모서리 어둠(화면 공간 AO) 설정. (원본 setAmbientOcclusion, 기본 꺼짐, 켜면 draw_ambient_occlusion 이 셈하고 몸 셰이더가 바탕빛에 곱한다)
  - `is_enabled` bool: 켤지.
  - `intensity` f64: 세기. (0 ~ 1 로 자름, 원본 기본 0.5)
  - `radius` f64: 가리는 것을 찾는 반지름. (월드 길이, 0.0001 이상, 원본 기본 0.5)
  - `resolution_scale` f64: 셈하는 판의 해상도 배율. (0.25 ~ 1 로 자름, 원본 기본 0.5)
  - `direct_lighting_strength` f64: 직접 빛(해, 채움빛, 점광의 확산과 반사광)에 미치는 몫. (0 ~ 1 로 자름, 원본 기본 0 이면 바탕빛에만)

  예제: 바깥선 없는 장면에 모서리 어둠을 켜고 그리기 줄에 맡기기

  ```rust
  use vanilla::{Matrix4, ToonDrawOptions, ToonDrawQueue, ToonMesh, ToonPostProcess, ToonRenderer};
  
  fn draw_room(gl: &vanilla::GlContext, renderer: &mut ToonRenderer, post_process: &mut ToonPostProcess, room_mesh: &ToonMesh, view_matrix: &Matrix4, projection_matrix: &Matrix4) {
  	post_process.set_ambient_occlusion(true, 0.5, 0.5, 0.5, 0.5);
  	assert_eq!(post_process.get_ambient_occlusion_direct_lighting_strength(), 0.5);
  	post_process.begin(gl, [0.1, 0.1, 0.12]);
  	{
  		let mut queue = ToonDrawQueue::new();
  		queue.set_post_process(Some(&mut *post_process));
  		queue.add_mesh(room_mesh, &Matrix4::create_identity(), ToonDrawOptions::default());
  		queue.draw_with_matrices(gl, renderer, view_matrix, projection_matrix);
  	}
  	post_process.end(gl, None, [0, 0, 640, 360]);
  }
  ```

- `pub fn get_ambient_occlusion(&self) -> ToonAmbientOcclusion` (method, since 0.4.0): 모서리 어둠 설정 반환. (원본 getAmbientOcclusion)
  - returns ToonAmbientOcclusion: 설정. (ToonAmbientOcclusion, 베낀 것)
- `pub fn get_ambient_occlusion_direct_lighting_strength(&self) -> f64` (method, since 0.4.0): 모서리 어둠이 직접 빛에 미치는 몫 반환. (원본 getAmbientOcclusionDirectLightingStrength, set_ambient_occlusion 의 다섯째 인자, 그리기 줄이 렌더러에 건다)
  - returns f64: 0 ~ 1.
- `pub fn is_ambient_occlusion_enabled(&self) -> bool` (method, since 0.4.0): 모서리 어둠을 켰는지. (원본 isAmbientOcclusionEnabled)
  - returns bool: set_ambient_occlusion 으로 켰으면 true.
- `pub fn get_ambient_occlusion_prepass(&mut self, gl: &GlContext) -> Result<&mut ToonScreenOutline, String>` (method, since 0.4.0): 바깥선이 없는 장면의 미리 그리기 반환. (원본 getAmbientOcclusionPrepass, 선 굵기 0 의 화면 바깥선, 처음 부를 때 짓는다)
  - `gl` &GlContext: 툰 렌더러와 같은 컨텍스트.
  - returns Result<&mut ToonScreenOutline, String>: 선의 판만 그리는 화면 바깥선. (begin_line_ids, draw_mesh, end_line_ids 로 그리고 get_line_target 을 draw_ambient_occlusion 에 준다) 짓지 못하면 Err(오류 글).
- `pub fn draw_ambient_occlusion_with_prepass(&mut self, gl: &GlContext, view_matrix: &Matrix4, projection_matrix: &Matrix4) -> Option<GlTexture>` (method, since 0.4.0): 미리 그리기의 선의 판으로 모서리 어둠 셈하기. (draw_ambient_occlusion 에 get_ambient_occlusion_prepass 의 선의 판을 준 것과 같다, 미리 그리기가 없거나 꺼졌으면 None)
  - `gl` &GlContext: GL 컨텍스트.
  - `view_matrix` &Matrix4: 선의 판을 그린 보기 행렬.
  - `projection_matrix` &Matrix4: 선의 판을 그린 투영 행렬.
  - returns Option<GlTexture>: 결과 텍스처. (draw_ambient_occlusion 과 같다)
- `pub fn draw_ambient_occlusion(&mut self, gl: &GlContext, line_target: &ToonLineTarget, view_matrix: &Matrix4, projection_matrix: &Matrix4) -> Option<GlTexture>` (method, since 0.4.0): 모서리 어둠 셈하기. (원본 drawAmbientOcclusion, 선의 판의 노멀과 깊이로 반 해상도 GTAO → 가로 흐림 → 세로 흐림과 키우기, 꺼졌으면 None)
  - 결과 텍스처는 선의 판 크기의 RGBA8 이다. (r 세기를 건 보임, gba 깊이 24 비트) ToonRenderer::set_ambient_occlusion_texture 에 준다.
  - 프레임버퍼, 뷰포트, 프로그램, 버텍스 어레이, 고른 텍스처 유닛, 깊이 시험, 섞기, 가위, 면 가리기를 되돌린다.
  - `gl` &GlContext: GL 컨텍스트.
  - `line_target` &ToonLineTarget: 이번 프레임의 선의 판. (ToonScreenOutline::get_line_target)
  - `view_matrix` &Matrix4: 선의 판을 그린 보기 행렬.
  - `projection_matrix` &Matrix4: 선의 판을 그린 투영 행렬.
  - returns Option<GlTexture>: 결과 텍스처. 꺼졌거나 판이나 셰이더를 짓지 못하면 None.
- `pub fn get_ambient_occlusion_texture(&self) -> Option<GlTexture>` (method, since 0.4.0): 모서리 어둠 결과 텍스처 반환. (원본 getAmbientOcclusionTexture, 아직 셈하지 않았거나 꺼졌으면 None)
  - returns Option<GlTexture>: 결과 텍스처. (RGBA8, r 보임, gba 깊이)

## ToonAmbientOcclusion (struct) (Clone, Copy, Debug, PartialEq, Default)

모서리 어둠 설정. (원본 getAmbientOcclusion 의 { isEnabled, intensity, radius, resolutionScale, directLightingStrength })

예제: 기본값 읽기

```rust
use vanilla::ToonAmbientOcclusion;

let ambient_occlusion = ToonAmbientOcclusion::default();
assert!(!ambient_occlusion.is_enabled);
assert_eq!((ambient_occlusion.intensity, ambient_occlusion.radius, ambient_occlusion.resolution_scale, ambient_occlusion.direct_lighting_strength), (0.5, 0.5, 0.5, 0.0));
```

- `pub is_enabled: bool` (field, since 0.4.0): 켰는지.
  - returns bool
- `pub intensity: f64` (field, since 0.4.0): 세기. (0 ~ 1, 0 이면 어둡히지 않는다)
  - returns f64
- `pub radius: f64` (field, since 0.4.0): 가리는 것을 찾는 반지름. (월드 길이)
  - returns f64
- `pub resolution_scale: f64` (field, since 0.4.0): 셈하는 판의 해상도 배율. (0.25 ~ 1, 선의 판 크기에 곱한다)
  - returns f64
- `pub direct_lighting_strength: f64` (field, since 0.4.0): 직접 빛에 미치는 몫. (0 ~ 1, URP 의 Direct Lighting Strength)
  - returns f64
