graphics3d/toon/toonlightset
툰 빛 묶음. (vanilla.js graphics3d/toon/toonlightset.js 의 ToonLightSet)
- ToonRenderer 가 몸을 칠할 빛과 툰 빛 반응을 한 덩어리로 든다. 렌더러는 기본 묶음 하나를 들고, set_light 같은 렌더러의 빛 설정은 그 묶음을 고친다. 그리기마다 ToonDrawOptions 의 light_set 으로 다른 묶음을 줄 수 있다. (재질마다 그늘 색이 다를 때)
- 해(주광): 방향(sun_direction)은 빛이 나아가는 쪽이다. 면에서 해 쪽을 가리키는 방향의 반대다. (위에서 내리쬐면 [0, -1, 0]) 그림자를 받는다.
- 바탕빛: 하늘색과 땅색을 노멀의 위아래(N.y x 0.5 + 0.5)로 섞는다. (반구 빛)
- 그늘 램프(셀 셰이딩): 빛을 받는 몫 x 를 램프에 대어 색을 고른다. x 는 반 램버트면 dot(N, L) x 0.5 + 0.5, 아니면 max(dot(N, L), 0) 이고, 그리기의 shade_offset 을 더한 뒤 해는 그림자(받는 몫 0 ~ 1)를 곱한다. (그림자가 검정이 아니라 그늘 색으로 들어간다, 유니티 툰 셰이더의 System Shadows) 램프는 칸(stop)마다 자리, 색(선형 배), 부드러움이다. 칸 i 의 색은 x 가 (자리 - 부드러움) 에서 자리까지 오를 때 앞 칸 색에서 넘어간다. (유니티 툰 셰이더의 Step 과 Feather) 부드러움이 화소 하나 너비(fwidth)보다 작으면 그 너비로 막아 경계가 계단지지 않는다. set_shade 는 바탕, 1 차 그늘, 2 차 그늘 셋으로, set_shade_ramp 는 칸을 바로, set_band_count 는 고른 칸으로, set_band_ramp 는 회색 칸으로 램프를 짓는다. set_ramp_texture 를 주면 칸 대신 그 텍스처의 가로(x 를 u 로, v 는 0.5)를 읽는다. 칸이 없으면(clear_shade_ramp, set_band_count(0)) 부드러운 램버트다.
- 빛마다: 해는 램프 색을 통째로 받아 그늘도 해의 색으로 물든다. 채움 빛, 점광, 스포트라이트는 램프의 밝기 단계(바닥 칸이 0, 맨 위 칸이 1)를 받아 등진 면을 밝히지 않는다.
- 채움 빛(fill): 그림자를 받지 않는 둘째 방향광. 방향의 뜻은 해와 같다. 기본 색 0 이면 없다.
- 하이라이트(정반사): 블린 퐁 pow(max(dot(N, H), 0), exponent) 를 0.5 에서 가른 단단한 점(부드러움 0)에서 그대로의 부드러운 빛(부드러움 1)까지. 색 x 세기 x 빛 색 x 빛을 받는 단계. 해와 점광, 스포트라이트 모두에 선다. 기본 세기 0 이면 없다.
- 림 빛(rim): pow(1 - max(dot(N, V), 0), power) 를 0.5 에서 가른 단단한 테(부드러움 0)에서 부드러운 테(1)까지. light_mask 가 1 이면 해를 받는 쪽에만. 바탕색과 상관없이 더한다. 그늘 쪽 림(set_shade_rim_light)은 같은 테를 해와 등진 쪽에 (테 - (dot(N, L) x 0.5 + 0.5)) 만큼 더한다. (유니티 툰 셰이더의 Antipodean(Ap) Rim Light)
- 빛 색 쓰기(set_light_color_usage): 색마다 빛 색을 곱할지 고른다. 끄면 바탕, 그늘, 하이라이트는 빛의 세기(0.299 R + 0.587 G + 0.114 B)만, 림과 매트캡과 천사 고리와 바깥선은 빛을 받지 않는다. (유니티 툰 셰이더의 Is_LightColor_*, 기본 모두 켬)
- 빛 세기 막기(set_light_intensity_limited): 빛마다 받은 몫을 1 로 막는다. 해와 채움 빛은 채널마다 1 로 자르고, 점광과 스포트라이트는 감쇠까지 곱한 색의 세기가 1 을 넘으면 세기로 나눈다. (유니티 툰 셰이더의 Limit Light Intensity, 기본 켬) HDR 블룸에 센 빛을 쓰려면 끈다. 옛 게임 셰이더(빛 세기를 막지 않던 것)를 옮길 때나 세기 1 을 넘는 점광, HDR 블룸을 쓸 때는 set_light_intensity_limited(false).
- 점광과 스포트라이트: TOON_MAXIMUM_POINT_LIGHTS 까지. (ToonPointLight) 감쇠는 창 x 거리 감쇠다. 창은 range 가 0 보다 크면 (1 - (거리 / range)^range_exponent) 를 0 ~ 1 로 막아 제곱, 0 이면 1. 거리 감쇠는 decay 가 0 보다 크면 1 / max(거리^decay, 0.01), 0 이면 1. casts_shadow 가 true 인 빛은 ShadowAtlas::update_lights(read_shadow_light_sources()) 가 그림자 칸을 준다. (점광은 큐브 여섯 면, 스포트라이트는 원근 한 칸) direction(빛이 나아가는 쪽)이 있으면 스포트라이트다. 각 감쇠는 glTF KHR_lights_punctual 꼴로 clamp(cos 각 x scale + offset, 0, 1) 의 제곱이다. 받는 몫은 감싸기(wrap) (dot(N, L) + wrap) / (1 + wrap) 이다. (0 이면 램버트, GPU Gems 1 의 wrap lighting)
- 빛 꼴: set_light_model(ToonLightModel { is_energy_normalized }) 가 true 면 바탕색 x 빛을 π 로 나누고 하이라이트에 (exponent + 8) / 8π 를 곱한다.
- 색은 모두 선형 색이다. (HDR 이면 1 을 넘어도 된다) 램프 텍스처는 sRGB 로 보고 선형으로 바꿔 읽는다. (감마 색 공간은 셰이더가 pow 2.2 로, 선형 색 공간은 sRGB 텍스처라 GPU 가)
- 고치면 판 번호(get_version)가 오른다. 렌더러는 묶음 번호(get_id)와 판 번호가 같으면 다시 올리지 않는다.
Toon light set. (ToonLightSet of vanilla.js graphics3d/toon/toonlightset.js)
- Holds as one bundle the lights ToonRenderer uses to shade bodies and the toon light response. The renderer holds one default set, and the renderer's light settings such as set_light change that set. Another set can be given per draw with light_set of ToonDrawOptions. (When the shade color differs per material)
- Sun (key light): the direction (sun_direction) is the way the light travels. It is the opposite of the direction from the surface toward the sun. ([0, -1, 0] when shining down from above) It receives shadows.
- Ambient light: sky color and ground color are mixed by the up and down of the normal (N.y x 0.5 + 0.5). (Hemisphere light)
- Shade ramp (cel shading): the received light amount x is laid against the ramp to pick the color. x is dot(N, L) x 0.5 + 0.5 for half Lambert, otherwise max(dot(N, L), 0), and after adding the draw's shade_offset, for the sun it is multiplied by the shadow (received amount 0 ~ 1). (Shadows enter as the shade color rather than black, System Shadows of the Unity Toon Shader) The ramp has a position, color (linear multiplier) and softness per cell (stop). The color of cell i transitions from the previous cell's color as x rises from (position - softness) to the position. (Step and Feather of the Unity Toon Shader) If the softness is smaller than one pixel width (fwidth), it is held at that width so the boundary does not stair-step. set_shade builds the ramp from three, base, 1st shade and 2nd shade, set_shade_ramp from cells directly, set_band_count from even cells, set_band_ramp from gray cells. If set_ramp_texture is given, the horizontal of that texture (x as u, v is 0.5) is read instead of cells. Without cells (clear_shade_ramp, set_band_count(0)) it is smooth Lambert.
- Per light: the sun receives the whole ramp color so the shade also takes on the sun's color. The fill light, point lights and spotlights receive the ramp's brightness level (bottom cell 0, top cell 1) and do not light faces turned away.
- Fill light (fill): a second directional light that receives no shadow. The direction means the same as the sun. With the default color 0 there is none.
- Highlight (specular): Blinn-Phong pow(max(dot(N, H), 0), exponent), from a hard spot cut at 0.5 (softness 0) to the plain soft light (softness 1). Color x strength x light color x received light level. It appears for the sun, point lights and spotlights alike. With the default strength 0 there is none.
- Rim light (rim): pow(1 - max(dot(N, V), 0), power), from a hard rim cut at 0.5 (softness 0) to a soft rim (1). If light_mask is 1, only on the side receiving the sun. Added regardless of the base color. The shade-side rim (set_shade_rim_light) adds the same rim on the side facing away from the sun by (rim - (dot(N, L) x 0.5 + 0.5)). (Antipodean (Ap) Rim Light of the Unity Toon Shader)
- Light color usage (set_light_color_usage): chooses per color whether the light color is multiplied. When off, the base, shade and highlight receive only the light's intensity (0.299 R + 0.587 G + 0.114 B), and the rim, matcap, angel ring and outline receive no light. (Is_LightColor_* of the Unity Toon Shader, all on by default)
- Light intensity limit (set_light_intensity_limited): limits what each light gives to 1. The sun and fill light are clamped to 1 per channel, and point lights and spotlights are divided by the intensity of their color with attenuation applied when it exceeds 1. (Limit Light Intensity of the Unity Toon Shader, on by default) Turn it off to use strong lights for HDR bloom. When porting an old game shader (one that did not limit light intensity), or when using point lights above intensity 1 or HDR bloom, use set_light_intensity_limited(false).
- Point lights and spotlights: up to TOON_MAXIMUM_POINT_LIGHTS. (ToonPointLight) Attenuation is window x distance attenuation. The window is (1 - (distance / range)^range_exponent) clamped to 0 ~ 1 and squared if range is above 0, and 1 if 0. Distance attenuation is 1 / max(distance^decay, 0.01) if decay is above 0, and 1 if 0. Lights with casts_shadow true get shadow tiles from ShadowAtlas::update_lights(read_shadow_light_sources()). (Six cube faces for a point light, one perspective tile for a spotlight) With direction (the way the light travels) it is a spotlight. Angular attenuation is the square of clamp(cos angle x scale + offset, 0, 1) in the glTF KHR_lights_punctual form. The received amount is the wrap (dot(N, L) + wrap) / (1 + wrap). (0 is Lambert, the wrap lighting of GPU Gems 1)
- Light model: if set_light_model(ToonLightModel { is_energy_normalized }) is true, base color x light is divided by π and the highlight is multiplied by (exponent + 8) / 8π.
- All colors are linear colors. (they may exceed 1 for HDR) The ramp texture is treated as sRGB and read converted to linear. (by the shader with pow 2.2 in the gamma color space, by the GPU as an sRGB texture in the linear color space)
- Each change raises the version number (get_version). The renderer does not upload again if the set ID (get_id) and version number are the same.
use vanilla::{ToonLightSet, ToonPointLight, ToonShade};
let mut light_set = ToonLightSet::new();
light_set.set_light([-0.4, -1.0, -0.3], [0.85, 0.82, 0.78], [0.3, 0.33, 0.42], [0.16, 0.15, 0.14]);
light_set.set_shade(ToonShade { step: 0.5, feather: 0.02, color: [0.55, 0.52, 0.7], second_step: 0.25, second_feather: 0.02, second_color: [0.36, 0.33, 0.52], is_half_lambert: true });
light_set.set_specular(0.6, 64.0, 0.0, [1.0, 1.0, 1.0]);
light_set.set_rim_light([0.5, 0.55, 0.7], 3.0, 0.2, 1.0);
light_set.set_point_lights(&[ToonPointLight { position: [0.0, 3.0, 0.0], color: [1.0, 0.8, 0.6], intensity: 3.0, range: 6.0, direction: Some([0.0, -1.0, 0.0]), inner_cone_angle: 0.3, outer_cone_angle: 0.6, ..ToonPointLight::default() }]);
assert_eq!(light_set.get_shade_ramp().positions.len(), 3);
assert_eq!(light_set.get_point_light_count(), 1);ToonPointLightstruct traits Clone, Copy, Debug, PartialEq, Default
점광이나 스포트라이트 하나. (원본 setPointLights 의 객체 하나)
One point light or spotlight. (one object of the original setPointLights)
use vanilla::{ToonLightSet, ToonPointLight};
let mut light_set = ToonLightSet::new();
light_set.set_point_lights(&[ToonPointLight { position: [0.0, 4.0, 0.0], color: [1.0, 0.9, 0.7], intensity: 4.0, range: 8.0, direction: Some([0.0, -1.0, 0.0]), inner_cone_angle: 0.25, outer_cone_angle: 0.5, ..ToonPointLight::default() }]);
assert_eq!(light_set.get_point_lights()[0].direction, Some([0.0, -1.0, 0.0]));거리 감쇠 지수. (0 이면 거리 감쇠 없음)
Distance attenuation exponent. (0 for no distance attenuation)
반환Returnsf64
빛이 나아가는 쪽. (Some 이면 스포트라이트)
Direction the light travels. (spotlight if Some)
반환ReturnsOption<[f64; 3]>
스포트라이트 안쪽 원뿔 반각. (라디안, 여기까지 다 밝다)
Inner cone half-angle of the spotlight. (radians, fully bright up to here)
반환Returnsf64
스포트라이트 바깥 원뿔 반각. (라디안, 여기서 0 이 된다)
Outer cone half-angle of the spotlight. (radians, reaches 0 here)
반환Returnsf64
그림자를 드리울지. (ShadowAtlas 가 칸을 준다)
Whether it casts a shadow. (ShadowAtlas gives it tiles)
반환Returnsbool
그림자의 가까운 거리. (먼 거리는 range, 0 이면 30)
Near distance of the shadow. (The far distance is range, 30 if 0)
반환Returnsf64
ToonLightColorUsagestruct traits Clone, Copy, Debug, PartialEq, Eq, Default
색마다 빛 색을 곱할지. (유니티 툰 셰이더의 Is_LightColor_*, 기본 모두 true)
- 바탕, 그늘, 하이라이트는 끄면 빛의 휘도(회색)를 받고, 나머지는 끄면 빛을 받지 않는다.
Whether to multiply the light color per color. (Is_LightColor_* of the Unity Toon Shader, all true by default)
- Base, shade and highlight receive the light's luminance (gray) when off, and the rest receive no light when off.
use vanilla::{ToonLightColorUsage, ToonLightSet};
let mut light_set = ToonLightSet::new();
light_set.set_light_color_usage(ToonLightColorUsage { shade: false, outline: false, ..ToonLightColorUsage::default() });
assert!(light_set.get_light_color_usage().base);
assert!(!light_set.get_light_color_usage().shade);ToonShadeRimLightstruct traits Clone, Copy, Debug, PartialEq
그늘 쪽 림 빛. (선형 색과 거듭제곱, 거듭제곱이 0 이하면 없음)
Shade-side rim light. (Linear color and power, none if the power is 0 or less)
use vanilla::ToonLightSet;
let mut light_set = ToonLightSet::new();
light_set.set_rim_light([0.8, 0.75, 0.6], 3.0, 0.1, 1.0);
light_set.set_shade_rim_light([0.2, 0.3, 0.6], 2.5);
assert_eq!(light_set.get_shade_rim_light().power, 2.5);ToonLightModelstruct traits Clone, Copy, Debug, Default, PartialEq
빛 꼴. (is_energy_normalized 바탕색 x 빛을 π 로 나눌지)
Light model. (is_energy_normalized whether to divide base color x light by π)
use vanilla::{ToonLightModel, ToonLightSet};
let mut light_set = ToonLightSet::new();
light_set.set_light_model(ToonLightModel { is_energy_normalized: true });
assert!(light_set.get_light_model().is_energy_normalized);바탕색 x 빛을 π 로 나눌지. (하이라이트에는 (exponent + 8) / 8π 를 곱한다, 기본 false)
Whether to divide base color x light by π. (the highlight is multiplied by (exponent + 8) / 8π, default false)
반환Returnsbool
ToonShadestruct traits Clone, Copy, Debug, PartialEq, Default
그늘 셋. (유니티 툰 셰이더의 바탕, 1 차 그늘, 2 차 그늘과 그 경계의 Step, Feather, second_step 이 0 이하면 2 차 그늘 없음)
Three shades. (base, 1st shade and 2nd shade of Unity Toon Shader with Step and Feather for their boundaries, no 2nd shade if second_step is 0 or less)
use vanilla::{ToonLightSet, ToonShade};
let mut light_set = ToonLightSet::new();
light_set.set_shade(ToonShade { step: 0.5, feather: 0.03, color: [0.8, 0.62, 0.6], second_step: 0.2, second_feather: 0.03, second_color: [0.5, 0.36, 0.42], is_half_lambert: true });
assert_eq!(light_set.get_shade_ramp().positions, vec![0.0, 0.2, 0.5]);바탕과 1 차 그늘의 경계. (빛을 받는 몫 x 의 자리, 반 램버트면 0.5 가 해와 직각인 면)
Boundary between base and 1st shade. (position on the light-receiving amount x, with half Lambert 0.5 is a face perpendicular to the sun)
반환Returnsf64
바탕과 1 차 그늘 경계의 부드러움.
Softness of the boundary between base and 1st shade.
반환Returnsf64
1 차 그늘 색. (바탕색과 빛에 곱하는 선형 배)
1st shade color. (linear factor multiplied by the base color and light)
반환Returns[f64; 3]
1 차와 2 차 그늘의 경계. (0 이하면 2 차 그늘 없음)
Boundary between 1st and 2nd shade. (no 2nd shade if 0 or less)
반환Returnsf64
1 차와 2 차 그늘 경계의 부드러움.
Softness of the boundary between 1st and 2nd shade.
반환Returnsf64
ToonShadeRampstruct traits Clone, Debug, Default, PartialEq
그늘 램프. (칸마다 자리, 선형 색, 부드러움, 칸이 비면 부드러운 램버트, 첫 칸의 자리와 부드러움은 쓰지 않는다)
Shade ramp. (position, linear color and softness per step, smooth Lambert if the steps are empty, the first step's position and softness are not used)
use vanilla::ToonLightSet;
let mut light_set = ToonLightSet::new();
light_set.set_shade_ramp(&[0.0, 0.4, 0.62], &[[0.3, 0.3, 0.45], [0.62, 0.6, 0.75], [1.0, 1.0, 1.0]], &[0.0, 0.05, 0.02], true);
let shade_ramp = light_set.get_shade_ramp();
assert_eq!(shade_ramp.positions, vec![0.0, 0.4, 0.62]);
assert!(shade_ramp.is_half_lambert);칸마다의 자리. (빛을 받는 몫 x, 오름차순)
Position of each cell. (received light amount x, ascending)
반환ReturnsVec<f64>
칸마다의 선형 [r, g, b] 배.
Linear [r, g, b] multiplier per cell.
반환ReturnsVec<[f64; 3]>
칸마다의 부드러움. (그 칸으로 넘어가는 너비)
Softness per cell. (Width of the transition into that cell)
반환ReturnsVec<f64>
x 를 dot x 0.5 + 0.5 로 셀지. (아니면 max(dot, 0))
Whether to count x as dot x 0.5 + 0.5. (Otherwise max(dot, 0))
반환Returnsbool
ToonRimLightstruct traits Clone, Copy, Debug, PartialEq
림 빛. (선형 색, 거듭제곱, 부드러움 0 ~ 1, 해를 받는 쪽에만 둘 몫 0 ~ 1)
Rim light. (linear color, power, softness 0 ~ 1, fraction kept only on the sunlit side 0 ~ 1)
use vanilla::ToonLightSet;
let mut light_set = ToonLightSet::new();
light_set.set_rim_light([0.6, 0.65, 0.8], 2.5, 0.0, 1.0);
let rim_light = light_set.get_rim_light();
assert_eq!((rim_light.feather, rim_light.light_mask), (0.0, 1.0));거듭제곱. (클수록 테가 가늘다, 0 이면 없음)
Power. (The larger, the thinner the rim, 0 means none)
반환Returnsf64
1 이면 해를 받는 쪽에만 테를 둔다. (0 ~ 1)
1 puts the rim only on the side receiving the sun. (0 ~ 1)
반환Returnsf64
ToonSpecularstruct traits Clone, Copy, Debug, PartialEq
하이라이트. (세기, 블린 퐁 지수, 부드러움 0 ~ 1, 선형 색)
Specular highlight. (strength, Blinn-Phong exponent, softness 0 ~ 1, linear color)
use vanilla::ToonLightSet;
let mut light_set = ToonLightSet::new();
light_set.set_specular(0.4, 32.0, 1.0, [1.0, 0.95, 0.9]);
assert_eq!(light_set.get_specular().exponent, 32.0);블린 퐁 지수. (클수록 작은 점, 1 밑으로 내리지 않는다)
Blinn-Phong exponent. (larger is a smaller spot, not lowered below 1)
반환Returnsf64
부드러움. (0 이면 단단한 툰 점, 1 이면 부드러운 블린 퐁)
Softness. (0 is a hard toon spot, 1 is soft Blinn-Phong)
반환Returnsf64
ToonLightSetstruct traits Debug, Default, Clone
툰 빛 묶음. (머리말 참고)
Toon light set. (see the header comment)
use vanilla::{create_sphere_geometry, Matrix4, MeshBuilder, ToonDrawOptions, ToonPartOptions, ToonRenderer, ToonShade, Vector3};
fn draw_skin(gl: &vanilla::GlContext, renderer: &mut ToonRenderer) -> Option<()> {
let mut skin_light_set = renderer.create_light_set();
skin_light_set.set_shade(ToonShade { step: 0.55, feather: 0.04, color: [0.86, 0.6, 0.6], ..ToonShade::default() });
let mut builder = MeshBuilder::new();
builder.add_part(&create_sphere_geometry(0.5, 32, 20, std::f64::consts::PI), &Matrix4::create_identity(), "#f0d0c0", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
let mesh = renderer.create_mesh(gl, &builder.read_arrays())?;
let view_matrix = Matrix4::create_look_at(Vector3::create(0.0, 0.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, 10.0));
renderer.draw_mesh(gl, &mesh, &Matrix4::create_identity(), ToonDrawOptions { light_set: Some(&skin_light_set), ..ToonDrawOptions::default() });
renderer.end_frame(gl);
Some(())
}생성. (기본은 반 램버트 0.5 에서 갈리는 두 단계 그늘, 그늘 색은 서늘한 보라)
Constructor. (by default two-step shading split at half Lambert 0.5, with a cool purple shade color)
반환ReturnsToonLightSet 새 빛 묶음. (번호는 묶음마다 다르다)New light set. (the ID differs per set)
짝Counterpart: vanilla.js ToonLightSet.constructor
번호 반환. (묶음마다 다르다, 복제하면 새 번호)
Returns the ID. (different per set, a clone gets a new ID)
반환Returnsu32 묶음 번호.Set number.
짝Counterpart: vanilla.js ToonLightSet.getId
판 번호 반환. (고칠 때마다 오른다)
Returns the version number. (raised on every modification)
반환Returnsu64 판 번호.Version number.
짝Counterpart: vanilla.js ToonLightSet.getVersion
pub fn set_light(&mut self, sun_direction: [f64; 3], sun_color: [f64; 3], sky_color: [f64; 3], ground_color: [f64; 3])#해와 바탕빛 설정. (해가 비추는 방향, 해의 색, 하늘색, 땅색, 모두 선형)
Sets the sun and ambient light. (direction the sun shines, sun color, sky color, ground color, all linear)
- sun_direction[f64; 3]
- 빛이 나아가는 쪽. [x, y, z]The way the light travels. [x, y, z]
- sun_color[f64; 3]
- 해의 선형 색과 세기. [r, g, b]Linear color and intensity of the sun. [r, g, b]
- sky_color[f64; 3]
- 위를 보는 면의 바탕빛. [r, g, b]Ambient light of faces looking up. [r, g, b]
- ground_color[f64; 3]
- 아래를 보는 면의 바탕빛. [r, g, b]Ambient light of faces looking down. [r, g, b]
짝Counterpart: vanilla.js ToonLightSet.setLight
해가 비추는 방향 설정. (빛이 나아가는 쪽, 면에서 해 쪽 방향이면 부호를 뒤집어 준다)
Sets the sun direction. (the way the light travels, flip the sign if you have the direction from the surface toward the sun)
- sun_direction[f64; 3]
- [x, y, z]
짝Counterpart: vanilla.js ToonLightSet.setSunDirection
해가 비추는 방향 반환. (ShadowMap::update_light_matrix 에 그대로 넘긴다)
Returns the sun direction. (pass it as is to ShadowMap::update_light_matrix)
반환Returns[f64; 3] [x, y, z]
짝Counterpart: vanilla.js ToonLightSet.getSunDirection
해의 색 반환.
Returns the sun color.
반환Returns[f64; 3] 선형 [r, g, b].Linear [r, g, b].
짝Counterpart: vanilla.js ToonLightSet.getSunColor
하늘색 반환.
Returns the sky color.
반환Returns[f64; 3] 선형 [r, g, b].Linear [r, g, b].
짝Counterpart: vanilla.js ToonLightSet.getSkyColor
땅색 반환.
Returns the ground color.
반환Returns[f64; 3] 선형 [r, g, b].Linear [r, g, b].
짝Counterpart: vanilla.js ToonLightSet.getGroundColor
채움 빛 설정. (빛이 나아가는 방향과 선형 색, 색이 0 이면 없음, 그림자를 받지 않음)
Sets the fill light. (direction the light travels and linear color, none if the color is 0, not shadowed)
- fill_direction[f64; 3]
- 빛이 나아가는 쪽. [x, y, z] (길이 1 로 맞춘다, 길이 0 이면 아래쪽)Direction the light travels. [x, y, z] (normalized to length 1, downward if the length is 0)
- fill_color[f64; 3]
- 선형 [r, g, b].Linear [r, g, b].
짝Counterpart: vanilla.js ToonLightSet.setFillLight
채움 빛 반환. ((방향, 색))
Returns the fill light. ((direction, color))
반환Returns([f64; 3], [f64; 3]) (방향, 색). (방향은 길이 1)(direction, color). (the direction has length 1)
짝Counterpart: vanilla.js ToonLightSet.getFillLight
pub fn set_rim_light(&mut self, rim_color: [f64; 3], rim_power: f64, rim_feather: f64, rim_light_mask: f64)#림 빛 설정. (선형 색, 거듭제곱, 부드러움 0 단단한 테 ~ 1 부드러운 테, 해를 받는 쪽에만 둘 몫 0 ~ 1, 거듭제곱이 0 이하면 없음)
Sets the rim light. (linear color, power, softness 0 hard rim ~ 1 soft rim, fraction kept only on the sunlit side 0 ~ 1, none if the power is 0 or less)
- rim_color[f64; 3]
- 더할 선형 색. [r, g, b]Linear color to add. [r, g, b]
- rim_powerf64
- 거듭제곱. (클수록 테가 가늘다, 0 이면 없음)Power. (The larger, the thinner the rim, 0 means none)
- rim_featherf64
- 0 이면 단단한 테, 1 이면 부드러운 테. (원본 기본 1)0 is a hard rim, 1 is a soft rim. (default 1 in the original)
- rim_light_maskf64
- 1 이면 해를 받는 쪽에만 테를 둔다. (원본 기본 0)1 puts the rim only on the side receiving the sun. (default 0 in the original)
짝Counterpart: vanilla.js ToonLightSet.setRimLight
림 빛 반환.
Returns the rim light.
반환ReturnsToonRimLight 림 빛. (색, 거듭제곱, 부드러움, 해를 받는 쪽에만 둘 몫)Rim light. (color, power, softness, share placed only on the side receiving the sun)
짝Counterpart: vanilla.js ToonLightSet.getRimLight
그늘 쪽 림 빛 설정. (해와 등진 쪽의 테, 선형 색, 거듭제곱, 부드러움은 set_rim_light 의 것을 같이 쓴다, 거듭제곱이 0 이하면 없음)
Sets the shade-side rim light. (Rim on the side facing away from the sun, linear color, power, softness is shared with set_rim_light, none if the power is 0 or less)
- shade_rim_color[f64; 3]
- 더할 선형 색. [r, g, b]Linear color to add. [r, g, b]
- shade_rim_powerf64
- 거듭제곱. (0 이면 없음)Power. (0 means none)
짝Counterpart: vanilla.js ToonLightSet.setShadeRimLight
그늘 쪽 림 빛 반환.
Return the shade-side rim light.
반환ReturnsToonShadeRimLight 그늘 쪽 림 빛. (색, 거듭제곱)Shade-side rim light. (color, power)
짝Counterpart: vanilla.js ToonLightSet.getShadeRimLight
빛 색 쓰기 설정. (색마다 빛 색을 곱할지)
Sets the light color usage. (Whether to multiply the light color per color)
- light_color_usageToonLightColorUsage
- 색마다 빛 색을 곱할지의 참 거짓. (바탕, 그늘, 하이라이트, 림, 그늘 쪽 림, 매트캡, 천사 고리, 껍데기 바깥선)Per-color flags for whether the light color is multiplied. (base, shade, highlight, rim, shade-side rim, matcap, angel ring, shell outline)
짝Counterpart: vanilla.js ToonLightSet.setLightColorUsage
빛 색 쓰기 반환.
Return the light color usage.
반환ReturnsToonLightColorUsage 색마다 빛 색을 곱할지의 참 거짓.Per-color flags for whether the light color is multiplied.
짝Counterpart: vanilla.js ToonLightSet.getLightColorUsage
빛 세기 막기 설정. (true 면 빛마다 받은 몫을 1 로 막아 하얗게 날지 않게 한다, 기본 true, 유니티 툰 셰이더의 Limit Light Intensity)
- 해와 채움 빛은 색의 채널마다 1 로 자른다. (주광의 saturate)
- 점광과 스포트라이트는 감쇠까지 곱한 색의 세기(0.299 R + 0.587 G + 0.114 B)가 1 을 넘으면 세기로 나눈다. (추가 빛의 min(색, 색 / 세기))
- 빛 꼴이 is_energy_normalized 면 π 로 나눈 뒤의 몫을 1 로 막는다.
- 옛 게임 셰이더(빛 세기를 막지 않던 것)를 옮길 때나 세기 1 을 넘는 점광, HDR 블룸을 쓸 때는 set_light_intensity_limited(false).
Sets light intensity limiting. (if true, each light's received share is limited to 1 so it does not blow out to white, default true, the Unity Toon Shader Limit Light Intensity)
- The sun and fill light clamp each color channel to 1. (saturate on the main light)
- Point lights and spot lights divide by the intensity when the intensity of the color including attenuation (0.299 R + 0.587 G + 0.114 B) exceeds 1. (min(color, color / intensity) for additional lights)
- If the light model is is_energy_normalized, the share after dividing by pi is limited to 1.
- When porting an old game shader (one that did not limit light intensity), or when using point lights above intensity 1 or HDR bloom, use set_light_intensity_limited(false).
- is_limitedbool
- true 면 막는다.If true, limits.
짝Counterpart: vanilla.js ToonLightSet.setLightIntensityLimited
빛 세기를 막는지 반환.
Returns whether light intensity is limited.
반환Returnsbool 막으면 true.true if limited.
짝Counterpart: vanilla.js ToonLightSet.isLightIntensityLimited
pub fn set_specular(&mut self, specular_strength: f64, specular_exponent: f64, specular_feather: f64, specular_color: [f64; 3])#하이라이트 설정. (세기 0 이면 없음, 지수가 클수록 작은 점, 부드러움 0 단단한 툰 점 ~ 1 부드러운 블린 퐁, 선형 색)
Sets the specular highlight. (none if the strength is 0, a larger exponent gives a smaller spot, softness 0 hard toon spot ~ 1 soft Blinn-Phong, linear color)
- specular_strengthf64
- 세기. (0 이면 없음)Strength. (0 means none)
- specular_exponentf64
- 블린 퐁 지수. (원본 기본 48, 1 밑으로 내리지 않는다)Blinn-Phong exponent. (default 48 in the original, not lowered below 1)
- specular_featherf64
- 0 ~ 1. (원본 기본 0, 단단한 점)0 ~ 1. (default 0 in the original, a hard spot)
- specular_color[f64; 3]
- 선형 [r, g, b]. (원본 기본 흰색)Linear [r, g, b]. (default white in the original)
짝Counterpart: vanilla.js ToonLightSet.setSpecular
하이라이트 반환.
Returns the specular highlight.
반환ReturnsToonSpecular 하이라이트. (세기, 지수, 부드러움, 색)Highlight. (strength, exponent, softness, color)
짝Counterpart: vanilla.js ToonLightSet.getSpecular
점광과 스포트라이트 설정. (TOON_MAXIMUM_POINT_LIGHTS 를 넘는 것은 버린다, 범위와 지수와 각은 0 밑으로 내리지 않고 방향은 길이 1 로)
Sets point lights and spotlights. (those beyond TOON_MAXIMUM_POINT_LIGHTS are discarded, range, exponents and angles are not lowered below 0, and directions are normalized to length 1)
- point_light_list&[ToonPointLight]
- 점광과 스포트라이트의 목록. (direction 이 Some 이면 스포트라이트)List of point lights and spotlights. (a spotlight if direction is Some)
짝Counterpart: vanilla.js ToonLightSet.setPointLights
점광 반환. (설정한 것 그대로, 한도로 자르기 전)
Returns the point lights. (as set, before clipping to the limit)
반환Returns&[ToonPointLight] set_point_lights 가 채운 꼴의 목록.List in the form filled by set_point_lights.
짝Counterpart: vanilla.js ToonLightSet.getPointLights
그림자 아틀라스에 줄 빛 꼴 읽기. (점광 목록 차례 그대로, ShadowAtlas::update_lights 에 넘긴다)
Reads the light descriptions to give to the shadow atlas. (In the same order as the point light list, passed to ShadowAtlas::update_lights)
반환ReturnsVec<ShadowAtlasLightSource> 점광마다 하나인 그림자 아틀라스 빛 꼴. (자리, 방향, 바깥 원뿔 반각, 범위, 그림자의 가까운 거리, 그림자를 드리울지)One shadow atlas light source per point light. (position, direction, outer cone half angle, range, shadow near distance, whether it casts shadows)
셰이더에 넣을 점광 수의 한도 설정. (0 ~ TOON_MAXIMUM_POINT_LIGHTS, 가벼운 길에서 줄인다)
Sets the limit on the number of point lights put into the shader. (0 ~ TOON_MAXIMUM_POINT_LIGHTS, lowered on lightweight paths)
- point_light_limitusize
- 한도.Limit.
짝Counterpart: vanilla.js ToonLightSet.setPointLightLimit
셰이더에 넣을 점광 수. (설정한 수와 한도 가운데 작은 것)
Number of point lights put into the shader. (the smaller of the set count and the limit)
반환Returnsusize 셰이더에 넣을 점광 수.Number of point lights put into the shader.
짝Counterpart: vanilla.js ToonLightSet.getPointLightCount
그늘 셋 설정. (ToonShade, 바탕은 흰색 [1, 1, 1])
Sets the three shades. (ToonShade, the base is white [1, 1, 1])
- shadeToonShade
- 그늘 셋. (경계와 부드러움과 색, 2 차 그늘, 반 램버트)Three shades. (boundaries, softness and colors, 2nd shade, half Lambert)
짝Counterpart: vanilla.js ToonLightSet.setShade
pub fn set_shade_ramp(&mut self, positions: &[f64], colors: &[[f64; 3]], feathers: &[f64], is_half_lambert: bool)#그늘 램프 설정. (칸마다 자리, 선형 색, 부드러움, 칸은 2 ~ TOON_MAXIMUM_BAND_STEPS, 둘보다 적으면 부드러운 램버트, 자리는 오름차순)
Sets the shade ramp. (position, linear color and softness per step, 2 ~ TOON_MAXIMUM_BAND_STEPS steps, smooth Lambert if fewer than two, positions in ascending order)
- positions&[f64]
- 칸마다의 자리. (빛을 받는 몫 x)Position per cell. (Received light amount x)
- colors&[[f64; 3]]
- 칸마다의 선형 [r, g, b] 배.Linear [r, g, b] multiplier per cell.
- feathers&[f64]
- 칸마다의 부드러움. (그 칸으로 넘어가는 너비)Softness per cell. (Width of the transition into that cell)
- is_half_lambertbool
- x 를 dot x 0.5 + 0.5 로 셀지. (아니면 max(dot, 0))Whether to count x as dot x 0.5 + 0.5. (Otherwise max(dot, 0))
짝Counterpart: vanilla.js ToonLightSet.setShadeRamp
그늘 램프 끄기. (부드러운 램버트)
Turns off the shade ramp. (smooth Lambert)
짝Counterpart: vanilla.js ToonLightSet.clearShadeRamp
그늘 램프 반환. (칸이 비면 부드러운 램버트)
Returns the shade ramp. (smooth Lambert if the steps are empty)
반환Returns&ToonShadeRamp 그늘 램프. (칸마다의 자리, 색, 부드러움과 반 램버트인지)Shade ramp. (position, color and softness per cell, and whether it is half Lambert)
짝Counterpart: vanilla.js ToonLightSet.getShadeRamp
고른 칸 설정. (max(dot(N, L), 0) 을 칸 수로 반올림한 회색 칸, 1 ~ TOON_MAXIMUM_BAND_STEPS - 1, 0 이면 부드러운 램버트)
Sets uniform bands. (gray bands from rounding max(dot(N, L), 0) to the band count, 1 ~ TOON_MAXIMUM_BAND_STEPS - 1, 0 for smooth Lambert)
- band_countu32
- 칸 수. (0 이면 부드럽게)Number of cells. (0 means smooth)
짝Counterpart: vanilla.js ToonLightSet.setBandCount
pub fn set_band_ramp(&mut self, thresholds: &[f64], values: &[f64], is_half_lambert: bool)#회색 칸 램프 설정. (문턱은 값보다 하나 적다, 값은 TOON_MAXIMUM_BAND_STEPS 까지, 첫 문턱 밑이 첫 값, 마지막 문턱 위가 마지막 값)
Sets the gray band ramp. (one fewer threshold than values, values up to TOON_MAXIMUM_BAND_STEPS, below the first threshold is the first value, above the last threshold is the last value)
- thresholds&[f64]
- 오름차순 문턱.Ascending thresholds.
- values&[f64]
- 칸마다의 받는 몫.Received amount per cell.
- is_half_lambertbool
- dot x 0.5 + 0.5 를 문턱에 댈지.Whether to compare dot x 0.5 + 0.5 to the thresholds.
짝Counterpart: vanilla.js ToonLightSet.setBandRamp
pub fn set_ramp_texture(&mut self, ramp_texture: Option<GlTexture>, is_half_lambert: bool)#램프 텍스처 설정. (칸 대신 텍스처의 가로를 읽는다, None 이면 칸으로, ToonRenderer::create_texture 로 지은 것, 왼쪽이 그늘 오른쪽이 빛)
Sets the ramp texture. (reads the texture horizontally instead of bands, None for bands, one built with ToonRenderer::create_texture, left is shade and right is light)
- ramp_textureOption<GlTexture>
- 램프 텍스처나 None.Ramp texture or None.
- is_half_lambertbool
- x 를 반 램버트로 셀지. (원본 기본 true)Whether to compute x as half Lambert. (default true in the original)
짝Counterpart: vanilla.js ToonLightSet.setRampTexture
램프 텍스처 반환. (없으면 None)
Returns the ramp texture. (None if none)
반환ReturnsOption<GlTexture> 램프 텍스처. (없으면 None)Ramp texture. (None if none)
짝Counterpart: vanilla.js ToonLightSet.getRampTexture
빛 꼴 설정.
Sets the light model.
- light_modelToonLightModel
- 빛 꼴. (is_energy_normalized)Light model. (is_energy_normalized)
짝Counterpart: vanilla.js ToonLightSet.setLightModel
빛 꼴 반환.
Returns the light model.
반환ReturnsToonLightModel 빛 꼴. (is_energy_normalized)Light model. (is_energy_normalized)
짝Counterpart: vanilla.js ToonLightSet.getLightModel
상수Constants
한 그리기에 받는 점광과 스포트라이트 수의 상한. (셰이더의 유니폼 배열 크기)
Maximum number of point lights and spotlights per draw. (uniform array size in the shader)
반환Returnsusize
짝Counterpart: vanilla.js TOON_MAXIMUM_POINT_LIGHTS
그늘 램프 칸 수의 상한. (셰이더의 유니폼 배열 크기)
Maximum number of shade ramp steps. (uniform array size in the shader)
반환Returnsusize
짝Counterpart: vanilla.js TOON_MAXIMUM_BAND_STEPS