#[allow(unused_imports)] use crate::{material::StrengthFactor, texture, validation::Validate, Extras};
use gltf_derive::Validate;
use serde_derive::{Deserialize, Serialize};
#[cfg(feature = "extensions")]
use serde_json::{Map, Value};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct Material {
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
#[serde(
default,
rename = "KHR_materials_pbrSpecularGlossiness",
skip_serializing_if = "Option::is_none"
)]
pub pbr_specular_glossiness: Option<PbrSpecularGlossiness>,
#[cfg(feature = "KHR_materials_unlit")]
#[serde(
default,
rename = "KHR_materials_unlit",
skip_serializing_if = "Option::is_none"
)]
pub unlit: Option<Unlit>,
#[cfg(feature = "KHR_materials_transmission")]
#[serde(
default,
rename = "KHR_materials_transmission",
skip_serializing_if = "Option::is_none"
)]
pub transmission: Option<Transmission>,
#[cfg(feature = "KHR_materials_volume")]
#[serde(
default,
rename = "KHR_materials_volume",
skip_serializing_if = "Option::is_none"
)]
pub volume: Option<Volume>,
#[cfg(feature = "KHR_materials_specular")]
#[serde(
default,
rename = "KHR_materials_specular",
skip_serializing_if = "Option::is_none"
)]
pub specular: Option<Specular>,
#[cfg(feature = "KHR_materials_ior")]
#[serde(
default,
rename = "KHR_materials_ior",
skip_serializing_if = "Option::is_none"
)]
pub ior: Option<Ior>,
#[cfg(feature = "KHR_materials_emissive_strength")]
#[serde(
default,
rename = "KHR_materials_emissive_strength",
skip_serializing_if = "Option::is_none"
)]
pub emissive_strength: Option<EmissiveStrength>,
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct PbrMetallicRoughness {
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
}
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
#[serde(default, rename_all = "camelCase")]
pub struct PbrSpecularGlossiness {
pub diffuse_factor: PbrDiffuseFactor,
#[serde(skip_serializing_if = "Option::is_none")]
pub diffuse_texture: Option<texture::Info>,
pub specular_factor: PbrSpecularFactor,
pub glossiness_factor: StrengthFactor,
#[serde(skip_serializing_if = "Option::is_none")]
pub specular_glossiness_texture: Option<texture::Info>,
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
#[cfg_attr(feature = "extras", serde(skip_serializing_if = "Option::is_none"))]
#[cfg_attr(not(feature = "extras"), serde(skip_serializing))]
pub extras: Extras,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct NormalTexture {
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct OcclusionTexture {
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
}
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct PbrDiffuseFactor(pub [f32; 4]);
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
impl Default for PbrDiffuseFactor {
fn default() -> Self {
PbrDiffuseFactor([1.0, 1.0, 1.0, 1.0])
}
}
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
impl Validate for PbrDiffuseFactor {}
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct PbrSpecularFactor(pub [f32; 3]);
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
impl Default for PbrSpecularFactor {
fn default() -> Self {
PbrSpecularFactor([1.0, 1.0, 1.0])
}
}
#[cfg(feature = "KHR_materials_pbrSpecularGlossiness")]
impl Validate for PbrSpecularFactor {}
#[cfg(feature = "KHR_materials_unlit")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct Unlit {}
#[cfg(feature = "KHR_materials_transmission")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct TransmissionFactor(pub f32);
#[cfg(feature = "KHR_materials_transmission")]
impl Default for TransmissionFactor {
fn default() -> Self {
TransmissionFactor(0.0)
}
}
#[cfg(feature = "KHR_materials_transmission")]
impl Validate for TransmissionFactor {}
#[cfg(feature = "KHR_materials_transmission")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
#[serde(default, rename_all = "camelCase")]
pub struct Transmission {
pub transmission_factor: TransmissionFactor,
#[serde(skip_serializing_if = "Option::is_none")]
pub transmission_texture: Option<texture::Info>,
#[cfg_attr(feature = "extras", serde(skip_serializing_if = "Option::is_none"))]
#[cfg_attr(not(feature = "extras"), serde(skip_serializing))]
pub extras: Extras,
}
#[cfg(feature = "KHR_materials_ior")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct IndexOfRefraction(pub f32);
#[cfg(feature = "KHR_materials_ior")]
impl Default for IndexOfRefraction {
fn default() -> Self {
IndexOfRefraction(1.5)
}
}
#[cfg(feature = "KHR_materials_ior")]
impl Validate for IndexOfRefraction {}
#[cfg(feature = "KHR_materials_ior")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
#[serde(default, rename_all = "camelCase")]
pub struct Ior {
pub ior: IndexOfRefraction,
#[cfg_attr(feature = "extras", serde(skip_serializing_if = "Option::is_none"))]
#[cfg_attr(not(feature = "extras"), serde(skip_serializing))]
pub extras: Extras,
}
#[cfg(feature = "KHR_materials_emissive_strength")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct EmissiveStrengthFactor(pub f32);
#[cfg(feature = "KHR_materials_emissive_strength")]
impl Default for EmissiveStrengthFactor {
fn default() -> Self {
EmissiveStrengthFactor(1.0)
}
}
#[cfg(feature = "KHR_materials_emissive_strength")]
impl Validate for EmissiveStrengthFactor {}
#[cfg(feature = "KHR_materials_emissive_strength")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
#[serde(default, rename_all = "camelCase")]
pub struct EmissiveStrength {
pub emissive_strength: EmissiveStrengthFactor,
}
#[cfg(feature = "KHR_materials_volume")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct ThicknessFactor(pub f32);
#[cfg(feature = "KHR_materials_volume")]
impl Default for ThicknessFactor {
fn default() -> Self {
ThicknessFactor(0.0)
}
}
#[cfg(feature = "KHR_materials_volume")]
impl Validate for ThicknessFactor {}
#[cfg(feature = "KHR_materials_volume")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct AttenuationDistance(pub f32);
#[cfg(feature = "KHR_materials_volume")]
impl Default for AttenuationDistance {
fn default() -> Self {
AttenuationDistance(f32::INFINITY)
}
}
#[cfg(feature = "KHR_materials_volume")]
impl Validate for AttenuationDistance {}
#[cfg(feature = "KHR_materials_volume")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct AttenuationColor(pub [f32; 3]);
#[cfg(feature = "KHR_materials_volume")]
impl Default for AttenuationColor {
fn default() -> Self {
AttenuationColor([1.0, 1.0, 1.0])
}
}
#[cfg(feature = "KHR_materials_volume")]
impl Validate for AttenuationColor {}
#[cfg(feature = "KHR_materials_volume")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
#[serde(default, rename_all = "camelCase")]
pub struct Volume {
pub thickness_factor: ThicknessFactor,
#[serde(skip_serializing_if = "Option::is_none")]
pub thickness_texture: Option<texture::Info>,
pub attenuation_distance: AttenuationDistance,
pub attenuation_color: AttenuationColor,
#[cfg_attr(feature = "extras", serde(skip_serializing_if = "Option::is_none"))]
#[cfg_attr(not(feature = "extras"), serde(skip_serializing))]
pub extras: Extras,
}
#[cfg(feature = "KHR_materials_specular")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct SpecularFactor(pub f32);
#[cfg(feature = "KHR_materials_specular")]
impl Default for SpecularFactor {
fn default() -> Self {
SpecularFactor(1.0)
}
}
#[cfg(feature = "KHR_materials_specular")]
impl Validate for SpecularFactor {}
#[cfg(feature = "KHR_materials_specular")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct SpecularColorFactor(pub [f32; 3]);
#[cfg(feature = "KHR_materials_specular")]
impl Default for SpecularColorFactor {
fn default() -> Self {
SpecularColorFactor([1.0, 1.0, 1.0])
}
}
#[cfg(feature = "KHR_materials_specular")]
impl Validate for SpecularColorFactor {}
#[cfg(feature = "KHR_materials_specular")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
#[serde(default, rename_all = "camelCase")]
pub struct Specular {
pub specular_factor: SpecularFactor,
#[serde(skip_serializing_if = "Option::is_none")]
pub specular_texture: Option<texture::Info>,
pub specular_color_factor: SpecularColorFactor,
#[serde(skip_serializing_if = "Option::is_none")]
pub specular_color_texture: Option<texture::Info>,
#[cfg_attr(feature = "extras", serde(skip_serializing_if = "Option::is_none"))]
#[cfg_attr(not(feature = "extras"), serde(skip_serializing))]
pub extras: Extras,
}