{
	"export": {

	},
	"export_last_target": "Godot/Godot 4",
	"name": "material_3d",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"albedo_color": {
			"a": 1,
			"b": 1,
			"g": 1,
			"r": 1,
			"type": "Color"
		},
		"ao": 1,
		"emission_energy": 1,
		"metallic": 0,
		"roughness": 1,
		"world": false
	},
	"seed_int": 0,
	"shader_model": {
		"shortdesc": "3D PBR Material",
		"longdesc": "PBR material with shader-generated maps based on input coordinates from 3D position in world or local space",
		"code": "",
		"custom": "",
		"exports": {
			"Godot/Godot 3": {
				"export_extension": "tres",
				"files": [
					{
						"file_name": "$(path_prefix).tres",
						"template": [
							"[gd_resource type=\"ShaderMaterial\" load_steps=2 format=2]",
							"[ext_resource path=\"$(file_prefix).gdshader\" type=\"Shader\" id=1]",
							"$begin_buffers",
							"[ext_resource path=\"$(file_prefix)_texture_$(buffer_index).png\" type=\"Texture\" id=$(expr:$(buffer_index)+1)]",
							"$end_buffers",
							"[resource]",
							"shader = ExtResource( 1 )",
							"$begin_buffers",
							"shader_param/texture_$(buffer_index) = ExtResource( $(expr:$(buffer_index)+1) )",
							"$end_buffers",
							""
						],
						"type": "template"
					},
					{
						"file_name": "$(path_prefix).gdshader",
						"template": [
							"shader_type spatial;",
							"render_mode blend_mix,depth_draw_alpha_prepass,cull_back,diffuse_burley,specular_schlick_ggx;",
							"varying vec3 texcoords_3d;",
							"$definitions",
							"void vertex() {",
							"$if $(param:world)",
							"\ttexcoords_3d = (vec4(VERTEX, 1.0)*WORLD_MATRIX).xyz;",
							"$else",
							"\ttexcoords_3d = VERTEX;",
							"$fi",
							"}",
							"void fragment() {",
							"\tfloat _seed_variation_ = 0.0;",
							"$begin_generate",
							"\tALBEDO = $albedo_color.rgb*$albedo_tex(vec4(texcoords_3d, 0.0));",
							"\tMETALLIC = $metallic*$metallic_tex(vec4(texcoords_3d, 0.0));",
							"\tROUGHNESS = $roughness*$roughness_tex(vec4(texcoords_3d, 0.0));",
							"\tSPECULAR = 0.5;",
							"\tEMISSION = $emission_energy*$emission_tex(vec4(texcoords_3d, 0.0));",
							"\tAO = $ao_tex(vec4(texcoords_3d, 0.0));",
							"\tAO_LIGHT_AFFECT = $ao;",
							"$end_generate",
							"}",
							""
						],
						"type": "template"
					},
					{
						"file_name": "$(path_prefix)_texture_$(buffer_index).png",
						"type": "buffers"
					}
				],
				"name": "Godot/Godot 3"
			},
			"Godot/Godot 4": {
				"export_extension": "tres",
				"files": [
					{
						"file_name": "$(path_prefix).tres",
						"template": [
							"[gd_resource type=\"ShaderMaterial\" load_steps=2 format=2]",
							"[ext_resource path=\"$(file_prefix).gdshader\" type=\"Shader\" id=1]",
							"$begin_buffers",
							"[ext_resource path=\"$(file_prefix)_texture_$(buffer_index).png\" type=\"Texture\" id=$(expr:$(buffer_index)+1)]",
							"$end_buffers",
							"[resource]",
							"shader = ExtResource( 1 )",
							"$begin_buffers",
							"shader_parameter/texture_$(buffer_index) = ExtResource( $(expr:$(buffer_index)+1) )",
							"$end_buffers",
							""
						],
						"type": "template"
					},
					{
						"file_name": "$(path_prefix).gdshader",
						"template": [
							"shader_type spatial;",
							"render_mode blend_mix,depth_prepass_alpha,cull_back,diffuse_burley,specular_schlick_ggx;",
							"varying vec3 texcoords_3d;",
							"$definitions",
							"void vertex() {",
							"$if $(param:world)",
							"\ttexcoords_3d = (vec4(VERTEX, 1.0)*WORLD_MATRIX).xyz;",
							"$else",
							"\ttexcoords_3d = VERTEX;",
							"$fi",
							"}",
							"void fragment() {",
							"\tfloat _seed_variation_ = 0.0;",
							"$begin_generate",
							"\tALBEDO = $albedo_color.rgb*$albedo_tex(vec4(texcoords_3d, 0.0));",
							"\tMETALLIC = $metallic*$metallic_tex(vec4(texcoords_3d, 0.0));",
							"\tROUGHNESS = $roughness*$roughness_tex(vec4(texcoords_3d, 0.0));",
							"\tSPECULAR = 0.5;",
							"\tEMISSION = $emission_energy*$emission_tex(vec4(texcoords_3d, 0.0));",
							"\tAO = $ao_tex(vec4(texcoords_3d, 0.0));",
							"\tAO_LIGHT_AFFECT = $ao;",
							"$end_generate",
							"}",
							""
						],
						"type": "template"
					},
					{
						"file_name": "$(path_prefix)_texture_$(buffer_index).png",
						"type": "buffers"
					}
				],
				"name": "Godot/Godot 3"
			},
			"Unity": {
				"export_extension": "mat",
				"files": [
					{
						"file_name": "$(path_prefix).shader",
						"template": [
							"Shader \"Custom/NewSurfaceShader\"",
							"{",
							"\tProperties {",
							"$begin_buffers",
							"\t\ttexture_$(buffer_index) (\"Texture $(buffer_index)\", 2D) = \"white\" {}",
							"$end_buffers",
							"\t}",
							"\tSubShader {",
							"\t\tTags { \"RenderType\"=\"Opaque\" }",
							"\t\tLOD 200",
							"\t\tCGPROGRAM",
							"\t\t#pragma surface surf Standard fullforwardshadows",
							"\t\t#pragma target 3.0",
							"\t\t",
							"\t\tstruct Input {",
							"\t\t\tfloat3 worldPos;",
							"\t\t};",
							"\t\tUNITY_INSTANCING_BUFFER_START(Props)",
							"\t\tUNITY_INSTANCING_BUFFER_END(Props)",
							"\t\t",
							"$definitions hlsl,rename_buffers,unity",
							"\t\t",
							"\t\tvoid surf (Input IN, inout SurfaceOutputStandard o) {",
							"\t\t\tfloat _seed_variation_ = 0.0;",
							"$if $(param:world)",
							"\t\t\tfloat3 texcoords_3d = IN.worldPos;",
							"$else",
							"\t\t\tfloat3 texcoords_3d = IN.worldPos -  mul(unity_ObjectToWorld, float4(0,0,0,1)).xyz;",
							"$fi",
							"$begin_generate hlsl,rename_buffers,unity",
							"\t\t\to.Albedo = $albedo_color.rgb*$albedo_tex(vec4(texcoords_3d, 0.0));",
							"\t\t\to.Metallic = $metallic*$metallic_tex(vec4(texcoords_3d, 0.0));",
							"\t\t\to.Smoothness = 1.0-$roughness*$roughness_tex(vec4(texcoords_3d, 0.0));",
							"\t\t\to.Alpha = 1.0;",
							"\t\t\to.Emission = $emission_energy*$emission_tex(vec4(texcoords_3d, 0.0));",
							"\t\t\to.Occlusion = $ao_tex(vec4(texcoords_3d, 0.0));",
							"$end_generate",
							"\t\t}",
							"\t\tENDCG",
							"\t}",
							"\tFallBack \"Diffuse\"",
							"}",
							""
						],
						"type": "template"
					},
					{
						"file_name": "$(path_prefix)_texture_$(buffer_index).png",
						"type": "buffers"
					},
					{
						"file_name": "$(path_prefix)_texture_$(buffer_index).png.meta",
						"template": [
							"fileFormatVersion: 2",
							"guid: $uid(tex_$(buffer_index))",
							"TextureImporter:",
							"  internalIDToNameTable: []",
							"  externalObjects: {}",
							"  serializedVersion: 11",
							"  mipmaps:",
							"\tmipMapMode: 0",
							"\tenableMipMap: 1",
							"\tsRGBTexture: 1",
							"\tlinearTexture: 0",
							"\tfadeOut: 0",
							"\tborderMipMap: 0",
							"\tmipMapsPreserveCoverage: 0",
							"\talphaTestReferenceValue: 0.5",
							"\tmipMapFadeDistanceStart: 1",
							"\tmipMapFadeDistanceEnd: 3",
							"  bumpmap:",
							"\tconvertToNormalMap: 0",
							"\texternalNormalMap: 0",
							"\theightScale: 0.25",
							"\tnormalMapFilter: 0",
							"  isReadable: 0",
							"  streamingMipmaps: 0",
							"  streamingMipmapsPriority: 0",
							"  vTOnly: 0",
							"  grayScaleToAlpha: 0",
							"  generateCubemap: 6",
							"  cubemapConvolution: 0",
							"  seamlessCubemap: 0",
							"  textureFormat: 1",
							"  maxTextureSize: 2048",
							"  textureSettings:",
							"\tserializedVersion: 2",
							"\tfilterMode: -1",
							"\taniso: -1",
							"\tmipBias: -100",
							"\twrapU: -1",
							"\twrapV: -1",
							"\twrapW: -1",
							"  nPOTScale: 1",
							"  lightmap: 0",
							"  compressionQuality: 50",
							"  spriteMode: 0",
							"  spriteExtrude: 1",
							"  spriteMeshType: 1",
							"  alignment: 0",
							"  spritePivot: {x: 0.5, y: 0.5}",
							"  spritePixelsToUnits: 100",
							"  spriteBorder: {x: 0, y: 0, z: 0, w: 0}",
							"  spriteGenerateFallbackPhysicsShape: 1",
							"  alphaUsage: 1",
							"  alphaIsTransparency: 0",
							"  spriteTessellationDetail: -1",
							"  textureType: 0",
							"  textureShape: 1",
							"  singleChannelComponent: 0",
							"  flipbookRows: 1",
							"  flipbookColumns: 1",
							"  maxTextureSizeSet: 0",
							"  compressionQualitySet: 0",
							"  textureFormatSet: 0",
							"  ignorePngGamma: 0",
							"  applyGammaDecoding: 0",
							"  platformSettings:",
							"  - serializedVersion: 3",
							"\tbuildTarget: DefaultTexturePlatform",
							"\tmaxTextureSize: 2048",
							"\tresizeAlgorithm: 0",
							"\ttextureFormat: -1",
							"\ttextureCompression: 1",
							"\tcompressionQuality: 50",
							"\tcrunchedCompression: 0",
							"\tallowsAlphaSplitting: 0",
							"\toverridden: 0",
							"\tandroidETC2FallbackOverride: 0",
							"\tforceMaximumCompressionQuality_BC6H_BC7: 0",
							"  spriteSheet:",
							"\tserializedVersion: 2",
							"\tsprites: []",
							"\toutline: []",
							"\tphysicsShape: []",
							"\tbones: []",
							"\tspriteID: ",
							"\tinternalID: 0",
							"\tvertices: []",
							"\tindices: ",
							"\tedges: []",
							"\tweights: []",
							"\tsecondaryTextures: []",
							"  spritePackingTag: ",
							"  pSDRemoveMatte: 0",
							"  pSDShowRemoveMatteOption: 0",
							"  userData: ",
							"  assetBundleName: ",
							"  assetBundleVariant: ",
							""
						],
						"type": "buffer_templates"
					},
					{
						"file_name": "$(path_prefix).mat",
						"template": [
							"%YAML 1.1",
							"%TAG !u! tag:unity3d.com,2011:",
							"--- !u!21 &2100000",
							"Material:",
							"  serializedVersion: 6",
							"  m_ObjectHideFlags: 0",
							"  m_CorrespondingSourceObject: {fileID: 0}",
							"  m_PrefabInstance: {fileID: 0}",
							"  m_PrefabAsset: {fileID: 0}",
							"  m_Name: $(file_prefix)",
							"  m_Shader: {fileID: 4800000, guid: $uid(shader), type: 3}",
							"  m_ShaderKeywords: ",
							"  m_LightmapFlags: 4",
							"  m_EnableInstancingVariants: 0",
							"  m_DoubleSidedGI: 0",
							"  m_CustomRenderQueue: -1",
							"  stringTagMap: {}",
							"  disabledShaderPasses: []",
							"  m_SavedProperties:",
							"\tserializedVersion: 3",
							"\tm_TexEnvs:",
							"\t- _MainTex:",
							"\t\tm_Texture: {fileID: 2800000, guid: 6c5d2d4e94384751a0ce7d6619e0d49a, type: 3}",
							"\t\tm_Scale: {x: 1, y: 1}",
							"\t\tm_Offset: {x: 0, y: 0}",
							"$begin_buffers",
							"\t- texture_$(buffer_index):",
							"\t\tm_Texture: {fileID: 2800000, guid: $uid(tex_$(buffer_index)), type: 3}",
							"\t\tm_Scale: {x: 1, y: 1}",
							"\t\tm_Offset: {x: 0, y: 0}",
							"$end_buffers",
							"  m_BuildTextureStacks: []",
							""
						],
						"type": "template"
					},
					{
						"file_name": "$(path_prefix).shader.meta",
						"template": [
							"fileFormatVersion: 2",
							"guid: $uid(shader)",
							"ShaderImporter:",
							"  externalObjects: {}",
							"  defaultTextures: []",
							"  nonModifiableTextures: []",
							"  preprocessorOverride: 0",
							"  userData: ",
							"  assetBundleName: ",
							"  assetBundleVariant: ",
							""
						],
						"type": "template"
					}
				]
			},
			"Unreal": {
				"export_extension": "mm2ue",
				"files": [
					{
						"file_name": "$(path_prefix).mm2ue",
						"template": [
							"/*",
							"Instructions to setup this material:",
							"- copy material_dynamic.uasset and open the copy",
							"$begin_buffers",
							"- create a TextureObject for $(file_prefix)_texture_$(buffer_index).png in the graph",
							"  and a new input for texture_$(buffer_index) in the custom node, and connect them",
							"$end_buffers",
							"- copy the shader code below and paste it into the Custom node",
							"*/",
							"struct Functions {",
							"$definitions hlsl,rename_buffers,unreal",
							"\tfixed4 generated_shader(float3 texcoords_3d, out float metallic, out float roughness, out float3 emission, out float occlusion) {",
							"\t\tfloat _seed_variation_ = 0.0;",
							"$begin_generate hlsl,rename_buffers,unreal",
							"\t\t// sample the generated texture",
							"\t\tfixed4 rv = tofloat4($albedo_tex(texcoords_3d), 1.0)*$albedo_color;",
							"\t\tmetallic = $metallic_tex(texcoords_3d)*$metallic;",
							"\t\troughness = $roughness_tex(texcoords_3d)*$roughness;",
							"\t\temission = $emission_energy*$emission_tex(vec4(texcoords_3d, 0.0));",
							"\t\tocclusion = $ao_tex(vec4(texcoords_3d, 0.0));",
							"\t\treturn rv;",
							"$end_generate",
							"\t}",
							"};",
							"Functions f;",
							"$if $(param:world)",
							"float3 coords = WorldCoords;",
							"$else",
							"float3 coords = LocalCoords;",
							"$fi",
							"fixed4 albedo = f.generated_shader(coords/Scale, metallic, roughness, emission, occlusion);",
							"return albedo;",
							""
						],
						"type": "template"
					},
					{
						"file_name": "$(path_prefix)_texture_$(buffer_index).png",
						"type": "buffers"
					}
				]
			}
		},
		"global": "",
		"inputs": [
			{
				"default": "vec3(1.0)",
				"group_size": 5,
				"label": "",
				"name": "albedo_tex",
				"type": "tex3d"
			},
			{
				"default": "1.0",
				"label": "",
				"name": "metallic_tex",
				"type": "tex3d_gs"
			},
			{
				"default": "1.0",
				"label": "",
				"name": "roughness_tex",
				"type": "tex3d_gs"
			},
			{
				"default": "vec3(0.0)",
				"label": "",
				"name": "emission_tex",
				"type": "tex3d"
			},
			{
				"default": "1.0",
				"label": "",
				"name": "ao_tex",
				"type": "tex3d_gs"
			}
		],
		"instance": "",
		"name": "3D PBR Material",
		"outputs": [

		],
		"parameters": [
			{
				"default": {
					"a": 1,
					"b": 1,
					"g": 1,
					"r": 1
				},
				"label": "Albedo",
				"name": "albedo_color",
				"type": "color"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Metallic",
				"max": 1,
				"min": 0,
				"name": "metallic",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Roughness",
				"max": 1,
				"min": 0,
				"name": "roughness",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Emission",
				"max": 1,
				"min": 0,
				"name": "emission_energy",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Ambient occlusion",
				"max": 1,
				"min": 0,
				"name": "ao",
				"step": 0.01,
				"type": "float"
			},
			{
				"default": true,
				"label": "World",
				"name": "world",
				"type": "boolean"
			}
		],
		"preview_shader": [
			"shader_type spatial;",
			"render_mode blend_mix,depth_prepass_alpha,cull_back,diffuse_burley,specular_schlick_ggx;",
			"",
			"varying vec3 texcoords_3d;",
			"",
			"$definitions",
			"",
			"void vertex() {",
			"$if $(param:world)",
			"\ttexcoords_3d = (vec4(VERTEX, 1.0)*MODEL_MATRIX).xyz;",
			"$else",
			"\ttexcoords_3d = VERTEX;",
			"$fi",
			"}",
			"",
			"void fragment() {",
			"\tfloat _seed_variation_ = 0.0;",
			"$begin_generate",
			"\tALBEDO = $albedo_color.rgb*$albedo_tex(vec4(texcoords_3d, 0.0));",
			"\tMETALLIC = $metallic*$metallic_tex(vec4(texcoords_3d, 0.0));",
			"\tROUGHNESS = $roughness*$roughness_tex(vec4(texcoords_3d, 0.0));",
			"\tSPECULAR = 0.5;",
			"\tEMISSION = $emission_energy*$emission_tex(vec4(texcoords_3d, 0.0));",
			"\tAO = $ao_tex(vec4(texcoords_3d, 0.0));",
			"\tAO_LIGHT_AFFECT = $ao;",
			"$end_generate",
			"}",
			""
		]
	},
	"type": "material_export"
}