# graphics3d/humanskinrenderer (vanilla-engine 0.4.0)

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

Human skin renderer. (the original graphics3d/humanskinrenderer.js)
- Builds skin / eye / hair shading templates on top of the SkinnedModelRenderer skinning/morph vertex path.
- Outputs irradiance / albedo / specular / normal split into MRT in linear HDR, and compositing is done by the caller after SubsurfaceScatteringEffect.
- Registers a shading mode per material (set_material_shading). The opaque pass (draw) draws skin / eye / hair cutout,
  and the blend pass (draw_blended) draws hair fringe / occlusion / fluid. (the caller sets the blend state)
- Environment state: 3 lights (0 = key light, receives shadows), 3-color hemisphere ambient, normal, detail, roughness, specular, wrinkle, micro, eye, hair parameters.
- The GLSL is the same as the original. ${WRINKLE_CHANNEL_COUNT} / ${SHADOW_SAMPLE_COUNT} / ${SKIN_SHADING_*} in the original template strings became numbers,
  and ${MORPH_GLSL} became MORPH_GLSL concatenated at construction. (a test checks that the numbers match the constants)
- Texture units: 0 = base_color, 1 = shadow map, 2 ~ 8 = material slots, 9 ~ 14 = extra skin slots, 15 = morph target texture.
- Differences from the original:
  - The original inherits from SkinnedModelRenderer. The Rust version embeds a SkinnedModelRenderer and uses Deref / DerefMut so the base functions
    (draw_wireframe, apply_morph_uniforms, set_sun_direction, get_shader_program ...) can be called as is.
    draw / draw_depth / set_shadow_map / set_shadow_strength, which the original redefines, call this type's functions first.
    It can be passed as is in place of the base renderer, as in SkinnedModel::load_from_bytes(gl, bytes, &human_skin_renderer). (Deref coercion)
  - The draw functions take gl and &mut SkinnedModel like the base renderer, and upload changed morph targets first.
  - The material shading mode table is keyed by material instance (Rc pointer), like the original `Map<Material, number>`.
  - set_ambient_colors / set_hair_parameters take fixed-length arrays instead of the original arrays. set_shadow_sample_count takes an integer and
    clamps it to 1 ~ 24 without the original Math.floor.
  - set_shadow_map copies the 16 matrix values like the base renderer. Construction returns shader compile failures as an error (Result).

## HumanSkinRenderer (struct) (Deref, DerefMut)

Human skin renderer.
- The output is four MRT targets. (0 diffuse irradiance + scattering mask, 1 linear albedo + coverage, 2 specular, 3 world normal)

Example: Pick shading modes by material name and draw to MRT targets in two passes, opaque and blend

```rust
use vanilla::{HumanSkinRenderer, Matrix4, RenderTarget, RenderTargetOptions, SkinnedModel, Vector3, SKIN_SHADING_EYE, SKIN_SHADING_HAIR};

fn create_head(gl: &vanilla::GlContext, glb_bytes: &[u8]) -> Result<(HumanSkinRenderer, SkinnedModel, RenderTarget), String> {
	let mut human_skin_renderer = HumanSkinRenderer::new(gl)?;
	let mut skinned_model = SkinnedModel::load_from_bytes(gl, glb_bytes, &human_skin_renderer)?;
	for drawable in skinned_model.get_drawable_list() {
		if drawable.material_name.contains("eyeball") {
			human_skin_renderer.set_material_shading(&drawable.material, SKIN_SHADING_EYE);
		}
		else if drawable.material_name.contains("hair") {
			human_skin_renderer.set_material_shading(&drawable.material, SKIN_SHADING_HAIR);
		}
	}
	skinned_model.update(0.0);
	let options = RenderTargetOptions { color_attachment_count: 4, use_float_color: true, use_depth_texture: true, ..RenderTargetOptions::default() };
	let scene_render_target = RenderTarget::new(gl, 1280, 720, true, Some(options))?;
	Ok((human_skin_renderer, skinned_model, scene_render_target))
}

fn render_head(gl: &vanilla::GlContext, human_skin_renderer: &HumanSkinRenderer, skinned_model: &mut SkinnedModel, scene_render_target: &RenderTarget) {
	let aspect_ratio = scene_render_target.get_width() as f64 / scene_render_target.get_height() as f64;
	let camera_position = Vector3::create(0.0, 1.6, 0.6);
	let view_matrix = Matrix4::create_look_at(camera_position, Vector3::create(0.0, 1.6, 0.0), Vector3::up());
	let mut view_projection_matrix = Matrix4::create_perspective(0.5, aspect_ratio, 0.05, 10.0);
	view_projection_matrix.multiply(&view_matrix);
	let model_matrix = Matrix4::create_identity();

	scene_render_target.bind(gl);
	unsafe {
		gl.clear_color(0.0, 0.0, 0.0, 0.0);
		gl.depth_mask(true);
		gl.clear(glow::COLOR_BUFFER_BIT | glow::DEPTH_BUFFER_BIT);
		gl.enable(glow::DEPTH_TEST);
	}
	human_skin_renderer.draw(gl, skinned_model, view_projection_matrix.get_elements(), model_matrix.get_elements(), camera_position.x, camera_position.y, camera_position.z);
	unsafe {
		gl.enable(glow::BLEND);
		gl.blend_func_separate(glow::SRC_ALPHA, glow::ONE_MINUS_SRC_ALPHA, glow::ZERO, glow::ONE);
		gl.depth_mask(false);
	}
	human_skin_renderer.draw_blended(gl, skinned_model, view_projection_matrix.get_elements(), model_matrix.get_elements(), camera_position.x, camera_position.y, camera_position.z);
	unsafe {
		gl.depth_mask(true);
		gl.disable(glow::BLEND);
	}
}
```

- `pub fn new(gl: &GlContext) -> Result<HumanSkinRenderer, String>` (constructor, since 0.4.0): Constructor. (base renderer with the skin shader injected + cutout depth shader, default 3-point lighting)
  - `gl` &GlContext: GL context. (taken out with Graphic::get_gl)
  - returns Result<HumanSkinRenderer, String>: New skin renderer. (default 3-point lighting, shadow strength 0, 12 shadow samples, hair fringe on, wrinkle maps off) Err(error message) if shader compilation fails.
- `pub fn draw(&self, gl: &GlContext, skinned_model: &mut SkinnedModel, view_projection_elements: &[f32; 16], model_matrix_elements: &[f32; 16], camera_x: f64, camera_y: f64, camera_z: f64)` (method, since 0.4.0): Draws the opaque pass. (skin / eye / hair cutout, depth writes)
  - Occlusion and fluid shading materials are skipped. The caller turns on depth test and writes.
  - `gl` &GlContext: GL context.
  - `skinned_model` &mut SkinnedModel: Model to draw. (changed morph targets are uploaded first)
  - `view_projection_elements` &[f32; 16]: Projection x view matrix elements. (column-major 4x4)
  - `model_matrix_elements` &[f32; 16]: Model matrix elements. (column-major 4x4)
  - `camera_x` f64: Camera world x. (for specular and view direction computation)
  - `camera_y` f64: Camera world y.
  - `camera_z` f64: Camera world z.
- `pub fn draw_blended(&self, gl: &GlContext, skinned_model: &mut SkinnedModel, view_projection_elements: &[f32; 16], model_matrix_elements: &[f32; 16], camera_x: f64, camera_y: f64, camera_z: f64)` (method, since 0.4.0): Draws the blend pass. (hair fringe / occlusion / fluid, called after the caller enables blending and disables depth writes)
  - Draws only hair and facial hair (when the fringe is on), occlusion and fluid materials.
  - `gl` &GlContext: GL context.
  - `skinned_model` &mut SkinnedModel: Model to draw. (changed morph targets are uploaded first)
  - `view_projection_elements` &[f32; 16]: Projection x view matrix elements. (column-major 4x4)
  - `model_matrix_elements` &[f32; 16]: Model matrix elements. (column-major 4x4)
  - `camera_x` f64: Camera world x. (for specular and view direction computation)
  - `camera_y` f64: Camera world y.
  - `camera_z` f64: Camera world z.

  Example: Enable alpha blending per attachment, disable depth writes, then draw the blend pass

  ```rust
  use vanilla::{HumanSkinRenderer, SkinnedModel};
  
  fn render_blended(gl: &vanilla::GlContext, human_skin_renderer: &HumanSkinRenderer, skinned_model: &mut SkinnedModel, view_projection_elements: &[f32; 16], model_matrix_elements: &[f32; 16]) {
  	unsafe {
  		gl.enable(glow::BLEND);
  		gl.blend_func_separate(glow::SRC_ALPHA, glow::ONE_MINUS_SRC_ALPHA, glow::ZERO, glow::ONE);
  		gl.depth_mask(false);
  	}
  	human_skin_renderer.draw_blended(gl, skinned_model, view_projection_elements, model_matrix_elements, 0.0, 1.6, 0.6);
  	unsafe {
  		gl.depth_mask(true);
  		gl.disable(glow::BLEND);
  	}
  }
  ```

- `pub fn draw_pass(&self, gl: &GlContext, skinned_model: &mut SkinnedModel, view_projection_elements: &[f32; 16], model_matrix_elements: &[f32; 16], camera_x: f64, camera_y: f64, camera_z: f64, pass_mode: i32)` (method, since 0.4.0): Draws a pass. (common uniforms → iterate drawables, only the shading modes matching the pass, pass_mode 0 = opaque, 1 = blend)
  - `gl` &GlContext: GL context.
  - `skinned_model` &mut SkinnedModel: Model to draw. (changed morph targets are uploaded first)
  - `view_projection_elements` &[f32; 16]: Projection x view matrix elements. (column-major 4x4)
  - `model_matrix_elements` &[f32; 16]: Model matrix elements. (column-major 4x4)
  - `camera_x` f64: Camera world x. (for specular and view direction computation)
  - `camera_y` f64: Camera world y.
  - `camera_z` f64: Camera world z.
  - `pass_mode` i32: Pass. (0 = opaque, 1 = blend)
- `pub fn draw_depth(&self, gl: &GlContext, skinned_model: &mut SkinnedModel, light_view_projection_elements: &[f32; 16], model_matrix_elements: &[f32; 16])` (method, since 0.4.0): Draws the depth pass. (shadow map casting, cutout / hair materials remove transparent areas with the coverage texture, occlusion / fluid excluded)
  - Bind the depth target with ShadowMap::begin_render before calling. The cutout pass binds the coverage texture to unit 0.
  - `gl` &GlContext: GL context.
  - `skinned_model` &mut SkinnedModel: Model to draw. (changed morph targets are uploaded first)
  - `light_view_projection_elements` &[f32; 16]: Light view-projection matrix elements. (elements of ShadowMap::get_light_view_projection_matrix)
  - `model_matrix_elements` &[f32; 16]: Model matrix elements. (column-major 4x4)

  Example: Draw depth into the key light shadow map and receive it in the main pass

  ```rust
  use vanilla::{HumanSkinRenderer, Matrix4, ShadowMap, SkinnedModel, Vector3};
  
  fn render_shadow(gl: &vanilla::GlContext, human_skin_renderer: &mut HumanSkinRenderer, shadow_map: &mut ShadowMap, skinned_model: &mut SkinnedModel) {
  	shadow_map.update_light_matrix(Vector3::create(0.0, 1.6, 0.0), Vector3::create(-0.45, -0.6, -0.65), 0.45, 0.2, 4.0);
  	let light_view_projection_elements = *shadow_map.get_light_view_projection_matrix().get_elements();
  	let model_matrix = Matrix4::create_identity();
  	shadow_map.begin_render(gl);
  	human_skin_renderer.draw_depth(gl, skinned_model, &light_view_projection_elements, model_matrix.get_elements());
  	let texel_size = 1.0 / shadow_map.get_resolution() as f64;
  	human_skin_renderer.set_shadow_map(Some(shadow_map.get_depth_texture()), Some(&light_view_projection_elements), texel_size);
  	human_skin_renderer.set_shadow_strength(0.85);
  }
  ```

- `pub fn apply_environment_uniforms(&self, gl: &GlContext, shader_program: &ShaderProgram)` (method, since 0.4.0): Applies the environment uniforms. (light / ambient / skin / wrinkle / micro / eye / hair parameters)
  - `gl` &GlContext: GL context.
  - `shader_program` &ShaderProgram: Shader to set the uniforms on. (must be the program currently in use)
- `pub fn apply_shadow_uniforms(&self, gl: &GlContext, shader_program: &ShaderProgram)` (method, since 0.4.0): Applies the shadow uniforms. (always bound regardless of strength so draws are not invalidated by a shadow sampler type mismatch)
  - If both the shadow map and the light matrix exist, the set strength is used, otherwise strength 0 and an empty shadow texture are bound.
  - `gl` &GlContext: GL context.
  - `shader_program` &ShaderProgram: Shader to set the uniforms on. (must be the program currently in use)
- `pub fn set_shadow_map(&mut self, shadow_map_texture: Option<GlTexture>, light_view_projection_elements: Option<&[f32; 16]>, texel_size: f64)` (method, since 0.4.0): Sets the shadow map. (receives shadows in the main pass, also passed to the base renderer, the matrix is copied)
  - `shadow_map_texture` Option<GlTexture>: Shadow depth texture. (no shadows are received when None)
  - `light_view_projection_elements` Option<&[f32; 16]>: Elements of the light view-projection matrix. (no shadows are received when None)
  - `texel_size` f64: Shadow texel size. (1 / shadow map resolution)
- `pub fn set_shadow_strength(&mut self, shadow_strength: f64)` (method, since 0.4.0): Sets the shadow strength. (0 = no receiving)
  - `shadow_strength` f64: Shadow strength. (0 receives none and 1 receives all, default 0)
- `pub fn set_shadow_softness(&mut self, shadow_softness: f64)` (method, since 0.4.0): Sets the shadow softness. (Poisson radius, in shadow texels)
  - `shadow_softness` f64: Radius for scattering Poisson samples. (in shadow texels, default 2.5)
- `pub fn set_shadow_sample_count(&mut self, shadow_sample_count: i32)` (method, since 0.4.0): Sets the shadow sample count. (1 ~ 24, more is smoother and slower)
  - `shadow_sample_count` i32: Sample count. (clamped to 1 ~ 24, default 12)
- `pub fn set_hair_sway(&mut self, amplitude: f64, time: f64, frequency: f64)` (method, since 0.4.0): Sets the hair sway. (amplitude m / time seconds / frequency, none if amplitude is 0)
  - `amplitude` f64: Amplitude. (meters, larger toward strand tips, no sway at 0, default 0)
  - `time` f64: Time. (seconds, give the elapsed time every frame)
  - `frequency` f64: Frequency. (default 1.5)

  Example: Sway the hair with the time elapsed every frame

  ```rust
  use vanilla::HumanSkinRenderer;
  
  fn update_hair(human_skin_renderer: &mut HumanSkinRenderer, elapsed_seconds: f64) {
  	human_skin_renderer.set_hair_sway(0.003, elapsed_seconds, 1.6);
  }
  ```

- `pub fn set_hair_fringe(&mut self, use_hair_fringe: bool)` (method, since 0.4.0): Sets whether hair fringe blending is used. (false means cutout only, performance first)
  - `use_hair_fringe` bool: If true, the hair and facial hair fringe is drawn in the blend pass. (default true)
- `pub fn set_material_shading(&mut self, material: &Rc<Material>, shading_mode: i32)` (method, since 0.4.0): Registers a material shading mode. (unregistered materials are skin, the same instance only has its value changed)
  - `material` &Rc<Material>: Material held by the drawable. (the instance is identified by its Rc pointer)
  - `shading_mode` i32: Shading mode. (constants such as SKIN_SHADING_SKIN, SKIN_SHADING_EYE)
- `pub fn get_material_shading_mode(&self, material: &Material) -> i32` (method, since 0.4.0): Returns the material shading mode.
  - `material` &Material: Material to look up.
  - returns i32: Registered shading mode. SKIN_SHADING_SKIN for an unregistered material.
- `pub fn set_light(&mut self, light_index: usize, direction_x: f64, direction_y: f64, direction_z: f64, red: f64, green: f64, blue: f64, intensity: f64)` (method, since 0.4.0): Sets a light. (0 = key light: receives the shadow map / 1 = fill / 2 = rim, direction is the vector from the surface toward the light)
  - `light_index` usize: Light index. (0 = key, 1 = fill, 2 = rim, 3 or more is ignored)
  - `direction_x` f64: x of the direction from the surface toward the light. (any length, normalized)
  - `direction_y` f64: y of the direction.
  - `direction_z` f64: z of the direction.
  - `red` f64: Red of the light color. (linear)
  - `green` f64: Green of the light color. (linear)
  - `blue` f64: Blue of the light color. (linear)
  - `intensity` f64: Intensity. (multiplied into the color)

  Example: A warm key light shining from above in front and a white rim light shining from behind

  ```rust
  use vanilla::HumanSkinRenderer;
  
  fn set_portrait_lights(human_skin_renderer: &mut HumanSkinRenderer) {
  	human_skin_renderer.set_light(0, 0.45, 0.6, 0.65, 1.0, 0.93, 0.85, 3.2);
  	human_skin_renderer.set_light(2, 0.5, 0.4, -0.75, 0.9, 0.95, 1.0, 2.2);
  }
  ```

- `pub fn set_ambient_colors(&mut self, sky_color: [f64; 3], horizon_color: [f64; 3], ground_color: [f64; 3])` (method, since 0.4.0): Sets the 3-color ambient. (sky / horizon / ground, linear color)
  - `sky_color` [f64; 3]: Color of upward-facing surfaces. (linear rgb, default (0.34, 0.36, 0.42))
  - `horizon_color` [f64; 3]: Color of sideways-facing surfaces. (linear rgb, default (0.16, 0.15, 0.16))
  - `ground_color` [f64; 3]: Color of downward-facing surfaces. (linear rgb, default (0.05, 0.04, 0.045))
- `pub fn set_normal_strength(&mut self, normal_strength: f64)` (method, since 0.4.0): Sets the normal map strength. (1 = original, larger makes wrinkles deeper)
  - `normal_strength` f64: Normal map xy multiplier. (1 = unchanged, default 1)
- `pub fn set_detail_strength(&mut self, detail_strength: f64)` (method, since 0.4.0): Sets the height detail strength. (0 = no detail normal)
  - `detail_strength` f64: Height detail normal strength. (none at 0, default 6)
- `pub fn set_detail_texel_size(&mut self, detail_texel_size: f64)` (method, since 0.4.0): Sets the height detail texel size. (1 / height map resolution)
  - `detail_texel_size` f64: UV size of one height map texel. (1 / height map resolution, default 1 / 4096)
- `pub fn set_cavity_strength(&mut self, cavity_strength: f64)` (method, since 0.4.0): Sets the cavity strength. (0 = no occlusion)
  - `cavity_strength` f64: Cavity strength. (darkens concave areas of the height map, none at 0, default 6)
- `pub fn set_roughness_range(&mut self, minimum_roughness: f64, maximum_roughness: f64)` (method, since 0.4.0): Sets the roughness range. (specular map 1 → minimum, 0 → maximum)
  - `minimum_roughness` f64: Roughness where the specular map is 1. (default 0.32)
  - `maximum_roughness` f64: Roughness where the specular map is 0. (default 0.62)
- `pub fn set_specular_strength(&mut self, specular_strength: f64)` (method, since 0.4.0): Sets the specular strength. (skin F0 multiplier)
  - `specular_strength` f64: Skin F0 multiplier. (default 1)
- `pub fn set_sheen_strength(&mut self, sheen_strength: f64)` (method, since 0.4.0): Sets the vellus hair scattering strength.
  - `sheen_strength` f64: Peach fuzz scattering strength. (brightness at grazing edges, default 0.35)
- `pub fn set_subsurface_amount(&mut self, subsurface_amount: f64)` (method, since 0.4.0): Sets the SSS mask strength. (irradiance output alpha, 0 excludes it from screen-space scattering)
  - `subsurface_amount` f64: SSS mask strength. (multiplied by the material's subsurface factor into the irradiance output alpha, default 1)
- `pub fn set_micro_detail(&mut self, micro_tiling: f64, micro_strength: f64)` (method, since 0.4.0): Sets the micro normal. (tiling count / strength, 0 means unused)
  - `micro_tiling` f64: Micro texture UV repeat count. (default 0)
  - `micro_strength` f64: Micro normal and cavity strength. (none at 0, default 0)
- `pub fn set_wrinkle_maps(&mut self, use_wrinkle_maps: bool, normal_strength: f64, color_strength: f64)` (method, since 0.4.0): Sets whether the wrinkle map is used. (the mask atlas / wrinkle normal / color atlas must be attached to the material)
  - `use_wrinkle_maps` bool: Whether to use wrinkle maps. (default false)
  - `normal_strength` f64: Wrinkle normal strength. (default 1)
  - `color_strength` f64: Wrinkle color strength. (default 1)
- `pub fn set_wrinkle_channel_weight(&mut self, channel_index: usize, weight1: f64, weight2: f64, weight3: f64)` (method, since 0.4.0): Sets a wrinkle channel weight. (channel = mask atlas tile x 4 + RGBA order, value = wrinkle map 1 / 2 / 3 contribution)
  - After setting them all, call finish_wrinkle_channel_weights so the shader reads the tiles that got weights.
  - `channel_index` usize: Channel index. (0 ~ 63, 64 or more is ignored)
  - `weight1` f64: Contribution weight of wrinkle map 1.
  - `weight2` f64: Contribution weight of wrinkle map 2.
  - `weight3` f64: Contribution weight of wrinkle map 3.

  Example: Apply wrinkle map 1 at about half to the four channels of the first tile and finish

  ```rust
  use vanilla::HumanSkinRenderer;
  
  fn apply_expression(human_skin_renderer: &mut HumanSkinRenderer) {
  	human_skin_renderer.set_wrinkle_maps(true, 1.0, 0.45);
  	for channel_index in 0..4 {
  		human_skin_renderer.set_wrinkle_channel_weight(channel_index, 0.5, 0.0, 0.0);
  	}
  	human_skin_renderer.finish_wrinkle_channel_weights();
  }
  ```

- `pub fn finish_wrinkle_channel_weights(&mut self)` (method, since 0.4.0): Finishes applying the wrinkle channel weights. (picks only the tiles with weights into a bitmask, the shader skips empty tiles)
- `pub fn set_eye_parameters(&mut self, iris_radius: f64, pupil_radius: f64, iris_depth: f64)` (method, since 0.4.0): Sets the eye parameters. (in UV units, iris radius / pupil radius / iris plane depth)
  - `iris_radius` f64: Iris radius. (UV units, default 0.133)
  - `pupil_radius` f64: Pupil radius. (UV units, default 0.04)
  - `iris_depth` f64: Iris plane depth. (amount of corneal refraction parallax, default 0.05)
- `pub fn set_eye_closure(&mut self, eye_closure: f64)` (method, since 0.4.0): Sets the eyelid closure. (0 = open eye, 1 = closed eye, darkens the eyeball by the eyelid shadow)
  - `eye_closure` f64: Closure amount. (0 = open eye, 1 = closed eye, clamped to 0 ~ 1)
- `pub fn set_hair_parameters(&mut self, specular_shift: [f64; 2], specular_power: [f64; 2], specular_intensity: [f64; 3], root_shade: f64)` (method, since 0.4.0): Sets hair parameters. (primary / secondary lobe shift, exponent, strength, transmission strength, root occlusion)
  - specular_shift: [primary, secondary], specular_power: [primary, secondary], specular_intensity: [primary, secondary, transmission]
  - `specular_shift` [f64; 2]: Primary and secondary lobe shift. (default `[-0.12, 0.14]`)
  - `specular_power` [f64; 2]: Primary and secondary lobe exponent. (default `[180.0, 28.0]`)
  - `specular_intensity` [f64; 3]: Primary and secondary lobe strength and transmission strength. (default `[0.35, 0.5, 0.25]`)
  - `root_shade` f64: Root occlusion. (none at 0, default 0.45)
- `pub fn get_cutout_depth_shader_program(&self) -> &ShaderProgram` (method, since 0.4.0): Returns the cutout depth shader program.
  - returns &ShaderProgram: Cutout depth shader program. (shadow depth pass for hair and alpha cutout materials)

## Functions and constants

- `pub const SKIN_SHADING_SKIN: i32 = 0` (field, since 0.4.0): Shading mode. (set per material with set_material_shading, branches within the same shader)
  - returns i32
- `pub const SKIN_SHADING_EYE: i32 = 1` (field, since 0.4.0): Eye. (reads the iris with corneal refraction parallax, sclera, pupil, corneal highlights)
  - returns i32
- `pub const SKIN_SHADING_HAIR: i32 = 2` (field, since 0.4.0): Hair. (card tangent anisotropic highlights, two passes of cutout and fringe blend, sway applied)
  - returns i32
- `pub const SKIN_SHADING_OCCLUSION: i32 = 3` (field, since 0.4.0): Eyelid occlusion mesh. (blend pass only, darkens only the irradiance)
  - returns i32
- `pub const SKIN_SHADING_FLUID: i32 = 4` (field, since 0.4.0): Fluids such as tear lines and saliva. (blend pass only, adds only specular)
  - returns i32
- `pub const SKIN_SHADING_FACIALHAIR: i32 = 5` (field, since 0.4.0): Facial hair such as eyebrows and beards. (same shading as hair, no sway)
  - returns i32
- `pub const SKIN_TEXTURE_UNIT_DETAILHEIGHT: u32 = 9` (field, since 0.4.0): Extra texture units. (9 to 14, avoiding the material base slots 0 / 2 to 8, shadow 1, and morph 15)
  - Skin: 9 detail height, 10 micro (normal rgb + cavity a), 11 wrinkle mask atlas (4x4), 12 wrinkle normal atlas (2x2), 13 wrinkle color atlas (2x2)
  - Eye: 12 iris normal, 13 iris color / Hair: 12 card tangent (rgb) + strand coordinate (a)
  - returns u32
- `pub const SKIN_TEXTURE_UNIT_MICRO: u32 = 10` (field, since 0.4.0): Micro normal (rgb) + cavity (a) unit. (uniform microTexture, repeated set_micro_detail times)
  - returns u32
- `pub const SKIN_TEXTURE_UNIT_MASKATLAS: u32 = 11` (field, since 0.4.0): Wrinkle mask atlas unit. (uniform maskAtlasTexture, 4x4 tiles x RGBA = 64 channels)
  - returns u32
- `pub const SKIN_TEXTURE_UNIT_LAYERNORMAL: u32 = 12` (field, since 0.4.0): Layer normal unit. (uniform layerNormalTexture, wrinkle normal atlas 2x2 for skin, iris normal for eyes, card tangent rgb + strand coordinate a for hair)
  - returns u32
- `pub const SKIN_TEXTURE_UNIT_LAYERCOLOR: u32 = 13` (field, since 0.4.0): Layer color unit. (uniform layerColorTexture, wrinkle color atlas 2x2 for skin, iris color for eyes)
  - returns u32
- `pub const SKIN_TEXTURE_UNIT_AUXILIARY: u32 = 14` (field, since 0.4.0): Auxiliary unit. (uniform auxiliaryTexture, declared in the shader but never read)
  - returns u32
- `pub const WRINKLE_CHANNEL_COUNT: usize = 64` (field, since 0.4.0): Wrinkle mask channel count. (4x4 atlas x RGBA, a vec3 of wrinkle map 1 / 2 / 3 contribution weights per channel)
  - returns usize
- `pub const SKIN_FRAGMENTSHADER_SOURCE: &str` (field, since 0.4.0): Human skin fragment shader. (linear HDR, outputs irradiance / albedo / specular separately for screen-space SSS)
  - Lighting: 3 directional lights (0 receives the shadow map) + 3-color hemisphere ambient + softbox reflection environment in the light directions.
  - Skin: normal map + expression wrinkle maps (weighted blend of the mask atlas) + tiling micro normal / cavity + height derivative detail, dual-lobe GGX, peach fuzz.
  - Eyes: samples the iris with corneal refraction parallax, iris normal / limbus / pupil, corneal glass highlights + environment reflection, scleral vein normals.
  - Hair: Kajiya-Kay dual-lobe anisotropic highlights from the card tangent atlas, root occlusion, transmitted backlight, 2 passes of cutout + fringe blend.
  - Occlusion / fluid: blend pass only, the eyelid occlusion mesh only darkens irradiance, tear lines / saliva only add specular.
  - Facial hair (eyebrows / beard): the same shading as hair but without sway.
  - Output 0: diffuse irradiance (rgb) + SSS mask (a) / 1: linear albedo (rgb) + coverage (a) / 2: specular (rgb) / 3: world normal (rgb).
  - returns &str
- `pub fn create_skin_vertex_shader_source() -> String` (method, since 0.4.0): Builds the skin vertex shader source. (the original SKIN_VERTEXSHADER_SOURCE, with the morph GLSL inserted in the middle)
  - returns String: Skin vertex shader GLSL. (first part + MORPH_GLSL + last part, starts with `#version 300 es`)
- `pub fn create_cutout_depth_vertex_shader_source() -> String` (method, since 0.4.0): Builds the cutout depth vertex shader source. (the original CUTOUT_DEPTH_VERTEXSHADER_SOURCE)
  - returns String: Cutout depth vertex shader GLSL. (first part + MORPH_GLSL + last part, starts with `#version 300 es`)
