{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "https://schema.stfform.at/stf.material.schema.json",
	"title": "STF Material",
	"description": "Represents a material for 3d surfaces.",
	"stfImplementations": {
		"blender": {
			"representingType": "bpy.types.Material",
			"link": "https://codeberg.org/stf_format/stf_blender/src/branch/master/stfblender/stf_resources/stf/stf_material/stf_material.py"
		},
		"godot": {
			"representingType": "Material",
			"link": "https://codeberg.org/stf_format/stf_godot/src/branch/master/addons/stf_godot/resources/stf/STF_Material.gd"
		},
		"unity": {
			"representingType": "Material",
			"link": "https://codeberg.org/stf_format/stf_unity/src/branch/master/Runtime/Resources/Resources_STF/STF_Material/STF_Material.cs",
			"extra_links": {
				"Default Processor": "https://codeberg.org/stf_format/stf_unity/src/branch/master/Runtime/Processors/Processors_STF/STF_Material_Processor.cs"
			}
		},
		"three.js": {
			"representingType": "MeshStandardMaterial",
			"link": "https://codeberg.org/stf_format/stf_js/src/branch/master/stf_threejs/src/stf_resources/stf_material.ts"
		}
	},
	"allOf": [{ "$ref": "https://schema.stfform.at/stf.schema.json#/$defs/stf_data_resource" }],
	"properties": {
		"type": {
			"const": "stf.material"
		},
		"style_hints": {
			"type": "array",
			"items": {
				"type": "string"
			},
			"examples": [
				[
					"realistic",
					"pbr"
				]
			],
			"description": "Hints for the visual style of the material."
		},
		"shader_targets": {
			"type": "object",
			"patternProperties": {
				".+": {
					"type": "array",
					"items": {
						"type": "string"
					}
				}
			},
			"examples": [
				{
					"blender": [
						"ShaderNodeBsdfPrincipled"
					],
					"unity": [
						".poiyomi/Poiyomi Toon",
						"Standard"
					]
				}
			],
			"description": "Hints for the target shaders per target application. If multiple target shaders are specified, the first available should be used."
		},
		"properties": {
			"type": "object",
			"patternProperties": {
				".+": {
					"type": "object",
					"title": "Material Property Values",
					"oneOf": [
						{
							"title": "Float Property Values",
							"properties": {
								"type": {
									"const": "float"
								},
								"values": {
									"type": "array",
									"items": {
										"type": "number"
									}
								}
							}
						},
						{
							"title": "Int Property Values",
							"properties": {
								"type": {
									"const": "int"
								},
								"values": {
									"type": "array",
									"items": {
										"type": "integer"
									}
								}
							}
						},
						{
							"title": "Color Property Values",
							"properties": {
								"type": {
									"const": "color"
								},
								"values": {
									"type": "array",
									"items": {
										"type": "array",
										"items": {
											"type": "number"
										},
										"minItems": 4,
										"maxItems": 4,
										"description": "Color (RGBA)"
									}
								}
							}
						},
						{
							"title": "Image Property Values",
							"properties": {
								"type": {
									"const": "image"
								},
								"values": {
									"type": "array",
									"items": {
										"type": "object",
										"title": "Image Reference",
										"properties": {
											"image": {
												"$ref": "https://schema.stfform.at/stf.schema.json#resource_ref",
												"description": "Resource Reference. The referenced resource must import into an image usable as a texture."
											}
										},
										"required": [
											"image"
										]
									},
									"stfExpand": true
								}
							}
						}
					],
					"stfExpand": true,
					"required": [
						"type",
						"values"
					]
				}
			},
			"examples": [
				{
					"albedo.texture": {
						"type": "image",
						"values": [
							{ "image": 0 }
						]
					},
					"albedo.color": {
						"type": "color",
						"values": [
							[0.78, 0.45, 0.78, 1.0]
						]
					},
					"specular.intensity": {
						"type": "float",
						"values": [
							0.8
						]
					},
					"decals.alphablend": {
						"type": "float",
						"values": [
							1.0,
							0.4,
							0.2
						]
					}
				}
			],
			"stfExpand": true
		}
	},
	"required": [
		"type",
		"properties"
	],
	"additionalProperties": false,
	"examples": [
		{
			"type": "stf.material",
			"name": "Body",
			"properties": {
				"albedo.texture": {
					"type": "image",
					"values": [
						{
							"image": 0
						}
					]
				},
				"roughness.texture": {
					"type": "image",
					"values": [
						{
							"image": 1
						}
					]
				},
				"metallic.texture": {
					"type": "image",
					"values": [
						{
							"image": 2
						}
					]
				},
				"normal.texture": {
					"type": "image",
					"values": [
						{
							"image": 3
						}
					]
				}
			},
			"style_hints": [
				"realistic",
				"pbr"
			],
			"shader_targets": {
				"blender": [
					"ShaderNodeBsdfPrincipled"
				]
			},
			"referenced_resources": [
				"f518a35d-d788-4692-a2dd-84d036d259e8",
				"edc8188f-7d85-419c-967f-5f7b427d8288",
				"5761ccd4-55bd-4fa5-ac98-f3d32004ac9e",
				"746f1aa1-5287-4d57-8892-e26fe631b953"
			]
		}
	]
}