vanilladocs
vanillapunch.com
API / graphics3d/toon/toonmaterial

graphics3d/toon/toonmaterial

툰 머티리얼과 인스턴스 꼴. (vanilla.js graphics3d/toon/toonmaterial.js)

  • ToonMaterial: ToonRenderer 의 몸 셰이더에 끼울 셰이더 조각, 게임마다의 확장 자리. 엔진의 표준 기능(텍스처, 빛, 틴트, 섞기)으로 되지 않는 무늬나 연출만 조각으로 넣는다. 조각이 없는 칸은 엔진의 빈 함수가 들어간다.
  • uniform_chunk: 조각 셰이더의 맨 위 칸에 들어간다. 유니폼, 상수, 함수, 정점 조각이 내보낸 in 을 적는다.
  • surface_chunk: void applySurface(inout ToonSurface surface) 를 정의한다. 엔진이 꼭짓점 색, 텍스처, 데칼을 셈한 뒤, 틴트와 빛 전에 부른다. ToonSurface { vec3 baseColor (감마 색 공간은 sRGB, 선형 색 공간은 선형, sRGB 색을 섞을 때는 toSurfaceColor 로 바꿔 넣는다), float alpha, vec3 emission (선형), vec3 normal (월드, 단위), float glow (꼭짓점 빛남), bool isUnlit, vec4 detail (꼭짓점 무늬 번호와 무늬 색), vec2 uv, vec2 uv1 (2 번 UV, 없으면 (0, 1)), vec3 localPosition (모형 좌표), vec3 worldPosition, vec3 viewDirection (면에서 카메라 쪽, 단위), float shadeOffset (빛을 받는 몫에 더할 값, 그늘 경계를 옮김), float specularMask (하이라이트 배), float rimMask (림 빛 배) }
  • light_chunk: void applyLight(ToonSurface surface, inout ToonLighting lighting) 를 정의한다. 엔진이 해, 바탕빛, 채움, 점광과 스포트라이트, 하이라이트, 림을 모은 뒤 합치기 전에 부른다. ToonLighting { vec3 irradiance (바탕색에 곱할 빛, 그늘 램프를 거친 것), vec3 specular (더할 하이라이트), vec3 rim (더할 림 빛), float shadow (0 ~ 1), float sunLevel (해를 받는 밝기 단계 0 ~ 1) } 합치기는 바탕색 x irradiance + specular x specularMask + rim x rimMask + 빛남 이다.
  • vertex_chunk: 정점 셰이더(몸, 바깥선, 그림자 깊이 셋 모두)의 맨 위 칸에 들어가고 void applyVertex(inout ToonVertex vertex) 를 정의한다. 월드로 옮기기 전에 부른다. ToonVertex { vec3 localPosition, vec3 localNormal, vec3 color, vec2 material, vec4 detail, vec2 uv, vec2 uv1, vec4 tint, vec4 emissive, mat4 modelMatrix } 인스턴스 꼴(ToonInstanceLayout)의 사용자 어트리뷰트는 그 이름의 in 으로 읽는다. 셋 모두에 들어가므로 몸에만 있는 out 은 쓰지 않는다. (꼭짓점 어트리뷰트 이름 대신 vertex 의 칸을 쓴다) 노멀은 mat3(modelMatrix) 로 옮긴다. 크기가 고르지 않으면 localNormal 을 그 크기의 제곱으로 나눠 둔다.
  • 셰이더에는 엔진의 toLinear(vec3) (sRGB 를 선형으로, 감마 색 공간은 pow 2.2, 선형 색 공간은 sRGB 표준 곡선), toSurfaceColor(vec3) (sRGB 를 baseColor 의 공간으로) 와 RECIPROCAL_PI 가 있다. 선형 색 공간(ColorSpace::Linear)이면 소스에 #define VANILLA_COLOR_SPACE_LINEAR 1 이 있고 엔진이 묶는 색 텍스처는 GPU 가 선형으로 풀어 준다. (ToonTextureOptions 의 is_color_data)
  • 텍스처는 그리기의 textures([(유니폼 이름, 텍스처)])로 넘긴다. 엔진이 쓰지 않는 유닛(8 부터, TOON_MAXIMUM_MATERIAL_TEXTURES 개까지)을 차례로 묶고 그 이름의 sampler2D 유니폼에 유닛을 넣는다.
  • 그리기마다 다른 유니폼은 on_before_draw(program, gl, ToonProgramKind) 에서 쓴다. 엔진의 유니폼은 엔진이 다시 쓰므로 머티리얼의 것만 쓴다.
  • ToonInstanceLayout: 인스턴스 하나의 어트리뷰트 차례. (ToonRenderer::create_instance_buffer 와 draw_mesh_instance_buffer 가 쓴다) 어트리뷰트마다 (이름, 크기). 이름이 instanceMatrix(16) 면 모형 행렬, instanceTint(4) 면 곱하는 색으로 엔진이 읽는다. instanceMatrix 는 아핀 3x4 로 읽고 아래 줄 네 칸(원소 3, 7, 11, 15)은 그 인스턴스의 빛남(sRGB r, g, b 와 선형 세기, vertex.emissive)이다. Matrix4 원소를 그대로 담으면 빛남이 없다. instanceLineId(1) 는 화면 공간 바깥선의 인스턴스마다 선 번호다. (ToonScreenOutline::draw_mesh_instance_buffer, ToonDrawQueue::add_mesh_instance_buffer) 사용자 어트리뷰트의 마지막 자리(TOON_INSTANCE_LINE_ID_LOCATION)를 쓰므로 이것이 있으면 사용자 어트리뷰트는 하나 적게 넣는다. 정점 조각도 그 이름으로 읽을 수 있다. 그 밖의 이름은 사용자 어트리뷰트다. TOON_MAXIMUM_INSTANCE_ATTRIBUTES 개까지, 크기 1 ~ 4. 정점 조각이 그 이름의 in 으로 읽는다. (자리 13 부터) instanceMatrix 가 없으면 모형 행렬은 단위 행렬이다. 정점 조각이 vertex.modelMatrix 를 지어 넣는다. instanceTint 가 없으면 틴트는 1 이다.
  • 원본은 머티리얼을 꼴 객체({ uniformChunk, ... })로 짓는다. 러스트 판은 ToonMaterialChunks 를 넘긴다.

Toon material and instance layout. (vanilla.js graphics3d/toon/toonmaterial.js)

  • ToonMaterial: shader chunks inserted into ToonRenderer's body shader, the per-game extension point. Only patterns and effects that the engine's standard features (textures, light, tint, blending) cannot do go into chunks. Slots without a chunk get the engine's empty functions.
  • uniform_chunk: goes into the top slot of the fragment shader. Write uniforms, constants, functions and the ins exported by the vertex chunk.
  • surface_chunk: defines void applySurface(inout ToonSurface surface). The engine calls it after computing the vertex color, textures and decal, before tint and light. ToonSurface { vec3 baseColor (sRGB in the gamma color space, linear in the linear color space; convert sRGB colors with toSurfaceColor before mixing them in), float alpha, vec3 emission (linear), vec3 normal (world, unit), float glow (vertex glow), bool isUnlit, vec4 detail (vertex pattern number and pattern color), vec2 uv, vec2 uv1 (second UV, (0, 1) if none), vec3 localPosition (model coordinates), vec3 worldPosition, vec3 viewDirection (from the surface toward the camera, unit), float shadeOffset (value added to the received light amount, moves the shade boundary), float specularMask (highlight multiplier), float rimMask (rim light multiplier) }
  • light_chunk: defines void applyLight(ToonSurface surface, inout ToonLighting lighting). The engine calls it after gathering the sun, ambient light, fill, point lights and spotlights, highlight and rim, before combining. ToonLighting { vec3 irradiance (light multiplied into the base color, after the shade ramp), vec3 specular (highlight to add), vec3 rim (rim light to add), float shadow (0 ~ 1), float sunLevel (brightness level of the received sun 0 ~ 1) } Combining is base color x irradiance + specular x specularMask + rim x rimMask + glow.
  • vertex_chunk: goes into the top slot of the vertex shaders (all three: body, outline, shadow depth) and defines void applyVertex(inout ToonVertex vertex). Called before moving into world space. ToonVertex { vec3 localPosition, vec3 localNormal, vec3 color, vec2 material, vec4 detail, vec2 uv, vec2 uv1, vec4 tint, vec4 emissive, mat4 modelMatrix } User attributes of the instance layout (ToonInstanceLayout) are read as ins of that name. Since it goes into all three, do not use outs that exist only in the body. (Use the fields of vertex instead of vertex attribute names) Normals are moved by mat3(modelMatrix). If the scale is not uniform, divide localNormal by the square of that scale beforehand.
  • The shader has the engine's toLinear(vec3) (sRGB to linear: pow 2.2 in the gamma color space, the standard sRGB curve in the linear color space), toSurfaceColor(vec3) (sRGB into the space of baseColor) and RECIPROCAL_PI. In the linear color space (ColorSpace::Linear), the source has #define VANILLA_COLOR_SPACE_LINEAR 1 and the color textures the engine binds are decoded to linear by the GPU. (is_color_data in ToonTextureOptions)
  • Textures are passed with the draw's textures ([(uniform name, texture)]). The engine binds them in order to units it does not use (from 8, up to TOON_MAXIMUM_MATERIAL_TEXTURES) and puts the unit into the sampler2D uniform of that name.
  • Uniforms that differ per draw are written in on_before_draw(program, gl, ToonProgramKind). The engine rewrites its own uniforms, so write only the material's.
  • ToonInstanceLayout: the attribute order of one instance. (used by ToonRenderer::create_instance_buffer and draw_mesh_instance_buffer) Each attribute is (name, size). The engine reads instanceMatrix (16) as the model matrix and instanceTint (4) as the multiplied color. instanceMatrix is read as an affine 3x4, and the four values of its bottom row (elements 3, 7, 11, 15) are the emission of that instance (sRGB r, g, b and linear intensity, vertex.emissive). Storing Matrix4 elements as they are gives no emission. instanceLineId (1) is the per-instance line id of the screen-space outline. (ToonScreenOutline::draw_mesh_instance_buffer, ToonDrawQueue::add_mesh_instance_buffer) It uses the last user attribute location (TOON_INSTANCE_LINE_ID_LOCATION), so with it one fewer user attribute fits. A vertex chunk can read it by that name too. Other names are user attributes. Up to TOON_MAXIMUM_INSTANCE_ATTRIBUTES, size 1 ~ 4. The vertex chunk reads them as ins of that name. (locations from 13) Without instanceMatrix the model matrix is the identity matrix. The vertex chunk builds vertex.modelMatrix. Without instanceTint the tint is 1.
  • The original builds a material from an options object ({ uniformChunk, ... }). The Rust version passes ToonMaterialChunks.
예제Example표면 조각으로 줄무늬를 넣고 텍스처와 유니폼을 그리기마다 넘기기Put stripes in with a surface chunk and pass a texture and uniforms per draw
use vanilla::{create_box_geometry, GlContext, Matrix4, MeshBuilder, ShaderProgram, ToonDrawOptions, ToonMaterialChunks, ToonPartOptions, ToonProgramKind, ToonRenderer, ToonTextureOptions, Vector3};

fn draw_stripe(gl: &vanilla::GlContext) -> Result<(), String> {
	let mut renderer = ToonRenderer::new(gl)?;
	let material = renderer.create_material(ToonMaterialChunks {
		name: String::from("stripe"),
		uniform_chunk: String::from("uniform sampler2D stripeTexture;\nuniform float stripeShift;\n"),
		surface_chunk: String::from("void applySurface(inout ToonSurface surface) {
			float stripe = texture(stripeTexture, vec2(surface.localPosition.y * 4.0 + stripeShift, 0.5)).r;
			surface.baseColor *= mix(0.5, 1.0, stripe);
		}"),
		..ToonMaterialChunks::default()
	});
	let stripe_texture = renderer.create_texture(gl, 2, 1, &[255, 255, 255, 255, 0, 0, 0, 255], ToonTextureOptions { is_mipmapped: false, ..ToonTextureOptions::default() })?;
	let mut builder = MeshBuilder::new();
	builder.add_part(&create_box_geometry(1.0, 1.0, 1.0), &Matrix4::create_identity(), "#80c0e0", 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));
	renderer.begin_frame_with_matrices(gl, &view_matrix, &Matrix4::create_perspective(0.8, 1.0, 0.1, 20.0));
	let set_shift = |program: &ShaderProgram, gl: &vanilla::GlContext, _kind: ToonProgramKind| unsafe {
		gl.uniform_1_f32(program.get_uniform_location(gl, "stripeShift").as_ref(), 0.25);
	};
	renderer.draw_mesh(gl, &mesh, &Matrix4::create_identity(), ToonDrawOptions {
		material: Some(&material),
		textures: &[("stripeTexture", stripe_texture)],
		on_before_draw: Some(&set_shift),
		..ToonDrawOptions::default()
	});
	renderer.end_frame(gl);
	Ok(())
}
Put stripes in with a surface chunk and pass a texture and uniforms per draw

ToonMaterialChunksstruct traits Clone, Debug, Default

소스source

머티리얼의 셰이더 조각. (빈 글이면 엔진의 빈 함수)

Shader snippets of the material. (the engine's empty functions for empty text)

예제Example표면 조각만 준 머티리얼Material with only a surface chunk
use vanilla::{ToonMaterial, ToonMaterialChunks};

let material = ToonMaterial::new(ToonMaterialChunks {
	name: String::from("darken"),
	surface_chunk: String::from("void applySurface(inout ToonSurface surface) { surface.baseColor *= 0.5; }"),
	..ToonMaterialChunks::default()
});
assert_eq!(material.get_name(), "darken");
assert!(material.get_light_chunk().is_empty());
필드fieldpub name: String#0.4.0 부터since 0.4.0소스source

이름. (알림 글에 쓴다)

Name. (used in notice messages)

반환ReturnsString

필드fieldpub uniform_chunk: String#0.4.0 부터since 0.4.0소스source

유니폼 조각. (조각 셰이더의 맨 위 칸, 유니폼, 상수, 함수, 정점 조각이 내보낸 in)

Uniform chunk. (top slot of the fragment shader, uniforms, constants, functions and the ins exported by the vertex chunk)

반환ReturnsString

필드fieldpub surface_chunk: String#0.4.0 부터since 0.4.0소스source

표면 조각. (void applySurface(inout ToonSurface surface) 를 정의한다)

Surface chunk. (defines void applySurface(inout ToonSurface surface))

반환ReturnsString

필드fieldpub light_chunk: String#0.4.0 부터since 0.4.0소스source

빛 조각. (void applyLight(ToonSurface surface, inout ToonLighting lighting) 를 정의한다)

Light chunk. (defines void applyLight(ToonSurface surface, inout ToonLighting lighting))

반환ReturnsString

필드fieldpub vertex_chunk: String#0.4.0 부터since 0.4.0소스source

정점 조각. (정점 셰이더 셋의 맨 위 칸, void applyVertex(inout ToonVertex vertex) 를 정의한다)

Vertex chunk. (top slot of the three vertex shaders, defines void applyVertex(inout ToonVertex vertex))

반환ReturnsString

ToonMaterialstruct traits Clone, Debug

짝Counterpart: vanilla.js ToonMaterial소스source

툰 머티리얼. (머리말 참고, 셰이더 조각과 번호)

Toon material. (see the header comment, shader snippets and an ID)

예제Example빛 조각으로 림을 키우고 정점 조각으로 기울이기Grow the rim with a light chunk and tilt with a vertex chunk
use vanilla::{ToonMaterialChunks, ToonRenderer};

fn prepare_lean_rim(gl: &vanilla::GlContext, renderer: &mut ToonRenderer) -> Result<(), String> {
	let material = renderer.create_material(ToonMaterialChunks {
		name: String::from("leanRim"),
		light_chunk: String::from("void applyLight(ToonSurface surface, inout ToonLighting lighting) { lighting.rim *= 2.0; }"),
		vertex_chunk: String::from("void applyVertex(inout ToonVertex vertex) { vertex.localPosition.x += vertex.localPosition.y * 0.2; }"),
		..ToonMaterialChunks::default()
	});
	if !renderer.prepare_material(gl, Some(&material), None) {
		return Err(format!("shader failed: {}", material.get_name()));
	}
	Ok(())
}
생성자constructorpub fn new(chunks: ToonMaterialChunks) -> ToonMaterial#0.4.0 부터since 0.4.0소스source

생성.

Constructor.

chunksToonMaterialChunks
이름과 셰이더 조각. (빈 글인 칸은 엔진의 빈 함수)Name and shader chunks. (slots with empty text get the engine's empty functions)

반환ReturnsToonMaterial 새 머티리얼. (번호는 머티리얼마다 다르다)New material. (the ID differs per material)

짝Counterpart: vanilla.js ToonMaterial.constructor

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

번호 반환. (머티리얼마다 다르다)

Returns the ID. (different per material)

반환Returnsu32 머티리얼 번호.Material number.

짝Counterpart: vanilla.js ToonMaterial.getId

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

이름 반환. (알림 글에 쓴다)

Returns the name. (used in notification messages)

반환Returns&str 이름. (주지 않았으면 빈 글)Name. (Empty text if not given)

짝Counterpart: vanilla.js ToonMaterial.getName

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

유니폼 조각 반환.

Returns the uniform chunk.

반환Returns&str 유니폼 조각. (없으면 빈 글)Uniform chunk. (Empty text if none)

짝Counterpart: vanilla.js ToonMaterial.getUniformChunk

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

표면 조각 반환.

Returns the surface chunk.

반환Returns&str 표면 조각. (없으면 빈 글)Surface chunk. (Empty text if none)

짝Counterpart: vanilla.js ToonMaterial.getSurfaceChunk

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

빛 조각 반환.

Returns the light chunk.

반환Returns&str 빛 조각. (없으면 빈 글)Light chunk. (Empty text if none)

짝Counterpart: vanilla.js ToonMaterial.getLightChunk

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

정점 조각 반환.

Returns the vertex chunk.

반환Returns&str 정점 조각. (없으면 빈 글)Vertex chunk. (Empty text if none)

짝Counterpart: vanilla.js ToonMaterial.getVertexChunk

ToonInstanceAttributestruct traits Clone, Debug, PartialEq, Eq

소스source

인스턴스 어트리뷰트 하나. (offset 은 수 단위, location 은 사용자 어트리뷰트만 Some)

One instance attribute. (offset is in values, location is Some only for user attributes)

예제Example사용자 어트리뷰트의 자리 읽기Read the locations of user attributes
use vanilla::ToonInstanceLayout;

let layout = ToonInstanceLayout::new(&[("instanceMatrix", 16), ("instanceShape", 4)]).unwrap();
let attributes = layout.get_attributes();
assert_eq!(attributes[0].location, None);
assert_eq!((attributes[1].offset, attributes[1].location), (16, Some(13)));
필드fieldpub name: String#0.4.0 부터since 0.4.0소스source

이름. (셰이더의 in 이름, instanceMatrix 와 instanceTint 는 엔진이 읽는다)

Name. (the in name in the shader, the engine reads instanceMatrix and instanceTint)

반환ReturnsString

필드fieldpub size: usize#0.4.0 부터since 0.4.0소스source

수 개수. (instanceMatrix 16, instanceTint 4, 사용자 어트리뷰트 1 ~ 4)

Number of floats. (instanceMatrix 16, instanceTint 4, user attributes 1 ~ 4)

반환Returnsusize

필드fieldpub offset: usize#0.4.0 부터since 0.4.0소스source

인스턴스 하나 안에서의 자리. (수 단위)

Position within one instance. (in floats)

반환Returnsusize

필드fieldpub location: Option<u32>#0.4.0 부터since 0.4.0소스source

어트리뷰트 자리. (사용자 어트리뷰트와 instanceLineId 만 Some, 사용자 어트리뷰트는 TOON_FIRST_INSTANCE_ATTRIBUTE_LOCATION 부터 차례로)

Attribute location. (Some only for user attributes and instanceLineId; user attributes go in order from TOON_FIRST_INSTANCE_ATTRIBUTE_LOCATION)

반환ReturnsOption<u32>

ToonInstanceLayoutstruct traits Clone, Debug

짝Counterpart: vanilla.js ToonInstanceLayout소스source

인스턴스 꼴. (머리말 참고, 어트리뷰트 이름과 크기의 차례)

Instance layout. (see the header comment, order of attribute names and sizes)

예제Example행렬 없이 자리와 크기만 담는 꼴A layout holding only position and size without a matrix
use vanilla::{ToonBufferUsage, ToonInstanceBuffer, ToonInstanceLayout, ToonMaterialChunks, ToonRenderer};

fn create_scatter(gl: &vanilla::GlContext, renderer: &mut ToonRenderer) -> Result<ToonInstanceBuffer, String> {
	let instance_layout = ToonInstanceLayout::new(&[("instanceOffset", 3), ("instanceScale", 1), ("instanceTint", 4)])?;
	let material = renderer.create_material(ToonMaterialChunks {
		name: String::from("scatter"),
		vertex_chunk: String::from("void applyVertex(inout ToonVertex vertex) { vertex.localPosition = vertex.localPosition * instanceScale + instanceOffset; }"),
		..ToonMaterialChunks::default()
	});
	renderer.prepare_material(gl, Some(&material), Some(&instance_layout));
	let data = [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 0.5, 1.0, 0.6, 0.6, 1.0];
	renderer.create_instance_buffer(gl, &instance_layout, &data, ToonBufferUsage::Static)
}
생성자constructorpub fn new(attributes: &[(&str, usize)]) -> Result<ToonInstanceLayout, String>#0.4.0 부터since 0.4.0소스source

생성. ((이름, 크기) 목록, 이름이 겹치거나, 크기가 맞지 않거나, 사용자 어트리뷰트가 너무 많으면 Err)

Constructor. ((name, size) list, Err if names overlap, sizes do not fit, or there are too many user attributes)

attributes&[(&str, usize)]
(이름, 크기) 의 배열.Array of (name, size).

반환ReturnsResult<ToonInstanceLayout, String> 지은 꼴. 이름이 셰이더 이름이 아니거나 겹치거나, 크기가 맞지 않거나, 사용자 어트리뷰트가 TOON_MAXIMUM_INSTANCE_ATTRIBUTES 개를 넘으면 Err(까닭 글).The built layout. Err(reason) if a name is not a shader name or is repeated, a size does not fit, or there are more than TOON_MAXIMUM_INSTANCE_ATTRIBUTES user attributes.

짝Counterpart: vanilla.js ToonInstanceLayout.constructor

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

번호 반환. (꼴마다 다르다)

Returns the ID. (different per layout)

반환Returnsu32 꼴 번호.Layout number.

짝Counterpart: vanilla.js ToonInstanceLayout.getId

메서드methodpub fn get_attributes(&self) -> &[ToonInstanceAttribute]#0.4.0 부터since 0.4.0소스source

어트리뷰트 목록 반환.

Returns the attribute list.

반환Returns&[ToonInstanceAttribute] 어트리뷰트 목록. (offset 은 수 단위, location 은 사용자 어트리뷰트만 Some)Attribute list. (offset is in floats, location is Some only for user attributes)

짝Counterpart: vanilla.js ToonInstanceLayout.getAttributes

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

인스턴스 하나의 수 개수.

Number of values per instance.

반환Returnsusize 인스턴스 하나의 수 개수.Number of values per instance.

짝Counterpart: vanilla.js ToonInstanceLayout.getFloatCount

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

모형 행렬이 있는지.

Whether it has a model matrix.

반환Returnsbool instanceMatrix 가 있으면 true.true if there is an instanceMatrix.

짝Counterpart: vanilla.js ToonInstanceLayout.hasMatrix

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

틴트가 있는지.

Whether it has a tint.

반환Returnsbool instanceTint 가 있으면 true.true if there is an instanceTint.

짝Counterpart: vanilla.js ToonInstanceLayout.hasTint

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

인스턴스마다의 선 번호가 있는지.

Whether there is a per-instance line id.

반환Returnsbool instanceLineId 가 있으면 true.true when instanceLineId is present.

짝Counterpart: vanilla.js ToonInstanceLayout.hasLineId

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

사용자 어트리뷰트의 셰이더 선언. (in float / vec2 / vec3 / vec4 이름;)

Shader declarations of the user attributes. (in float / vec2 / vec3 / vec4 name;)

반환ReturnsString 사용자 어트리뷰트마다 한 줄인 in 선언. (없으면 빈 글)in declarations, one line per user attribute. (Empty text if none)

짝Counterpart: vanilla.js ToonInstanceLayout.readDeclarationSource

상수Constants

상수constantpub const TOON_MAXIMUM_INSTANCE_ATTRIBUTES: usize = 3#0.4.0 부터since 0.4.0소스source

인스턴스 꼴에 넣을 수 있는 사용자 어트리뷰트 수의 상한. (어트리뷰트 자리 13, 14, 15)

Upper limit on the number of user attributes in an instance layout. (attribute locations 13, 14, 15)

반환Returnsusize

짝Counterpart: vanilla.js TOON_MAXIMUM_INSTANCE_ATTRIBUTES

상수constantpub const TOON_FIRST_INSTANCE_ATTRIBUTE_LOCATION: u32 = 13#0.4.0 부터since 0.4.0소스source

사용자 인스턴스 어트리뷰트의 첫 자리.

First location of the user instance attributes.

반환Returnsu32

짝Counterpart: vanilla.js TOON_FIRST_INSTANCE_ATTRIBUTE_LOCATION

상수constantpub const TOON_INSTANCE_MATRIX_NAME: &str = "instanceMatrix"#0.4.0 부터since 0.4.0소스source

인스턴스 꼴에서 엔진이 모형 행렬로 읽는 이름. (수 16)

Name the engine reads as the model matrix in an instance layout. (16 floats)

반환Returns&str

짝Counterpart: vanilla.js TOON_INSTANCE_MATRIX_NAME

상수constantpub const TOON_INSTANCE_TINT_NAME: &str = "instanceTint"#0.4.0 부터since 0.4.0소스source

인스턴스 꼴에서 엔진이 곱하는 색으로 읽는 이름. (수 4)

Name the engine reads as the multiplied color in an instance layout. (4 floats)

반환Returns&str

짝Counterpart: vanilla.js TOON_INSTANCE_TINT_NAME

상수constantpub const TOON_INSTANCE_LINE_ID_NAME: &str = "instanceLineId"#0.4.0 부터since 0.4.0소스source

인스턴스 꼴에서 화면 공간 바깥선이 인스턴스마다의 선 번호로 읽는 이름. (수 1, 1 ~ TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID)

Name the screen-space outline reads as the per-instance line id in an instance layout. (1 float, 1 to TOON_SCREEN_OUTLINE_MAXIMUM_LINE_ID)

반환Returns&str

짝Counterpart: vanilla.js TOON_INSTANCE_LINE_ID_NAME

상수constantpub const TOON_INSTANCE_LINE_ID_LOCATION: u32#0.4.0 부터since 0.4.0소스source

선 번호 어트리뷰트의 자리. (사용자 어트리뷰트의 마지막 자리, 선의 판 셰이더가 이 자리에서 읽는다)

Location of the line id attribute. (the last user attribute location; the line board shader reads from it)

반환Returnsu32

짝Counterpart: vanilla.js TOON_INSTANCE_LINE_ID_LOCATION

ToonBlendModeenum traits Clone, Copy, Debug, Default, PartialEq, Eq

짝Counterpart: vanilla.js ToonBlendMode소스source

섞는 방식. (Alpha 는 곧은 알파 SRC_ALPHA, Premultiplied 는 미리 곱한 알파 ONE, Additive 는 더하기 ONE, ONE)

Blend mode. (Alpha is straight alpha SRC_ALPHA, Premultiplied is premultiplied alpha ONE, Additive is additive ONE, ONE)

이름Name설명Description
Alpha곧은 알파. (SRC_ALPHA, ONE_MINUS_SRC_ALPHA)Straight alpha. (SRC_ALPHA, ONE_MINUS_SRC_ALPHA)
Premultiplied미리 곱한 알파. (ONE, ONE_MINUS_SRC_ALPHA)Premultiplied alpha. (ONE, ONE_MINUS_SRC_ALPHA)
Additive더하기. (ONE, ONE)Additive. (ONE, ONE)

ToonMatcapBlendenum traits Clone, Copy, Debug, Default, PartialEq, Eq

짝Counterpart: vanilla.js ToonMatcapBlend소스source

매트캡을 섞는 방식. (Multiply 는 색에 곱함, Add 는 색에 더함, 유니티 툰 셰이더의 MatCap 섞기와 같다)

How matcaps are blended. (Multiply multiplies the color, Add adds to the color, same as the MatCap blending of Unity Toon Shader)

이름Name설명Description
Multiply색에 곱한다.Multiplies into the color.
Add색에 더한다.Adds to the color.

ToonBufferUsageenum traits Clone, Copy, Debug, Default, PartialEq, Eq

짝Counterpart: vanilla.js ToonBufferUsage소스source

인스턴스 버퍼의 쓰임. (Static 은 한 번 올리고 오래 그림, Dynamic 은 자주 고침)

Usage of the instance buffer. (Static is uploaded once and drawn for a long time, Dynamic is modified often)

이름Name설명Description
Static한 번 올려 오래 쓴다. (STATIC_DRAW)Uploaded once and used for a long time. (STATIC_DRAW)
Dynamic자주 고친다. (DYNAMIC_DRAW)Changed often. (DYNAMIC_DRAW)