Added 3D PBR material node

This commit is contained in:
Rodz Labs 2021-10-03 14:21:38 +02:00
parent f0ab310e72
commit 827cbac99e
1 changed files with 194 additions and 0 deletions

View File

@ -0,0 +1,194 @@
{
"export": {
},
"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": true
},
"seed": 0,
"seed_locked": false,
"shader_model": {
"code": "",
"custom": "",
"exports": {
"Godot": {
"export_extension": "tres",
"files": [
{
"file_name": "$(path_prefix).tres",
"template": "[gd_resource type=\"ShaderMaterial\" load_steps=2 format=2]\n[ext_resource path=\"$(file_prefix).shader\" type=\"Shader\" id=1]\n$begin_buffers\n[ext_resource path=\"res://$(file_prefix)_texture_$(buffer_index).png\" type=\"Texture\" id=$(expr:$(buffer_index)+1)]\n$end_buffers\n[resource]\nshader = ExtResource( 1 )\n$begin_buffers\nshader_param/texture_$(buffer_index) = ExtResource( $(expr:$(buffer_index)+1) )\n$end_buffers\n",
"type": "template"
},
{
"file_name": "$(path_prefix).shader",
"template": "shader_type spatial;\nrender_mode blend_mix,depth_draw_alpha_prepass,cull_back,diffuse_burley,specular_schlick_ggx;\n\nvarying vec3 texcoords_3d;\n\n$definitions\n\nvoid vertex() {\n$if $(param:world)\n\ttexcoords_3d = (vec4(VERTEX, 1.0)*WORLD_MATRIX).xyz;\n$else\n\ttexcoords_3d = VERTEX;\n$fi\n}\n\nvoid fragment() {\n\tfloat _seed_variation_ = 0.0;\n$begin_generate\n\tALBEDO = $albedo_color.rgb*$albedo_tex(vec4(texcoords_3d, 0.0));\n\tMETALLIC = $metallic*$metallic_tex(vec4(texcoords_3d, 0.0));\n\tROUGHNESS = $roughness*$roughness_tex(vec4(texcoords_3d, 0.0));\n\tSPECULAR = 0.5;\n\tEMISSION = $emission_energy*$emission_tex(vec4(texcoords_3d, 0.0));\n\tAO = $ao_tex(vec4(texcoords_3d, 0.0));\n\tAO_LIGHT_AFFECT = $ao;\n$end_generate\n}\n",
"type": "template"
},
{
"file_name": "$(path_prefix)_texture_$(buffer_index).png",
"type": "buffers"
}
]
},
"Unity": {
"export_extension": "mat",
"files": [
{
"file_name": "$(path_prefix).shader",
"template": "Shader \"Custom/NewSurfaceShader\"\n{\n Properties {\n$begin_buffers\n\t texture_$(buffer_index) (\"Texture $(buffer_index)\", 2D) = \"white\" {}\n$end_buffers\n\t _MainTex (\"Foo\", 2D) = \"white\" {}\n }\n SubShader {\n Tags { \"RenderType\"=\"Opaque\" }\n LOD 200\n CGPROGRAM\n #pragma surface surf Standard fullforwardshadows\n #pragma target 3.0\n\t\t\n sampler2D _MainTex;\n struct Input {\n float2 uv_MainTex;\n };\n UNITY_INSTANCING_BUFFER_START(Props)\n UNITY_INSTANCING_BUFFER_END(Props)\n\t\t\n$definitions hlsl,rename_buffers,unity\n\t\t\n void surf (Input IN, inout SurfaceOutputStandard o) {\n\t\t\tfloat2 uv = IN.uv_MainTex;\n$begin_generate hlsl,rename_buffers,unity\n\t\t\to.Albedo = $albedo_tex(uv).rgb*$albedo_color.rgb;\n o.Metallic = $metallic_tex(uv)*$metallic;\n o.Smoothness = 1.0-$roughness_tex(uv)*$roughness;\n o.Alpha = 1.0;\n\t\t\to.Normal = $normal_tex(uv)*vec3(-1.0, 1.0, -1.0)+vec3(1.0, 0.0, 1.0);\n$end_generate\n }\n ENDCG\n }\n FallBack \"Diffuse\"\n}\n",
"type": "template"
},
{
"file_name": "$(path_prefix)_texture_$(buffer_index).png",
"type": "buffers"
},
{
"file_name": "$(path_prefix)_texture_$(buffer_index).png.meta",
"template": "fileFormatVersion: 2\nguid: $uid(tex_$(buffer_index))\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 11\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n vTOnly: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n flipbookRows: 1\n flipbookColumns: 1\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n ignorePngGamma: 0\n applyGammaDecoding: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n",
"type": "buffer_templates"
},
{
"file_name": "$(path_prefix).mat",
"template": "%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!21 &2100000\nMaterial:\n serializedVersion: 6\n m_ObjectHideFlags: 0\n m_CorrespondingSourceObject: {fileID: 0}\n m_PrefabInstance: {fileID: 0}\n m_PrefabAsset: {fileID: 0}\n m_Name: test2\n m_Shader: {fileID: 4800000, guid: $uid(shader), type: 3}\n m_ShaderKeywords: \n m_LightmapFlags: 4\n m_EnableInstancingVariants: 0\n m_DoubleSidedGI: 0\n m_CustomRenderQueue: -1\n stringTagMap: {}\n disabledShaderPasses: []\n m_SavedProperties:\n serializedVersion: 3\n m_TexEnvs:\n - _MainTex:\n m_Texture: {fileID: 2800000, guid: 6c5d2d4e94384751a0ce7d6619e0d49a, type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$begin_buffers\n - texture_$(buffer_index):\n m_Texture: {fileID: 2800000, guid: $uid(tex_$(buffer_index)), type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$end_buffers\n m_BuildTextureStacks: []\n",
"type": "template"
},
{
"file_name": "$(path_prefix).shader.meta",
"template": "fileFormatVersion: 2\nguid: $uid(shader)\nShaderImporter:\n externalObjects: {}\n defaultTextures: []\n nonModifiableTextures: []\n preprocessorOverride: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n",
"type": "template"
}
]
},
"Unreal": {
"export_extension": "mm2ue",
"files": [
{
"file_name": "$(path_prefix).mm2ue",
"template": "/*\nInstructions to setup this material:\n- copy material_dynamic.uasset and open the copy\n$begin_buffers\n- create a TextureObject for $(file_prefix)_texture_$(buffer_index).png in the graph\n and a new input for texture_$(buffer_index) in the custom node, and connect them\n$end_buffers\n- copy the shader code below and paste it into the Custom node\n*/\nstruct Functions {\n$definitions hlsl,rename_buffers,unreal\n\tfixed4 generated_shader(float2 uv, out float metallic, out float roughness, out float3 normal) {\n$begin_generate hlsl,rename_buffers,unreal\n // sample the generated texture\n\t\tfixed4 rv = tofloat4($albedo_tex(uv), 1.0)*$albedo_color;\n\t\tmetallic = $metallic_tex(uv)*$metallic;\n\t\troughness = $roughness_tex(uv)*$roughness;\n\t\tnormal = $normal_tex(uv)*float3(-1.0, -1.0, -1.0)+float3(1.0, 1.0, 1.0);\n return rv;\n$end_generate\n }\n};\nFunctions f;\nfixed4 albedo = f.generated_shader(TexCoords, metallic, roughness, normal);\nreturn albedo;\n",
"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;\nrender_mode blend_mix,depth_draw_alpha_prepass,cull_back,diffuse_burley,specular_schlick_ggx;\n\nvarying vec3 texcoords_3d;\n\n$definitions\n\nvoid vertex() {\n$if $(param:world)\n\ttexcoords_3d = (vec4(VERTEX, 1.0)*WORLD_MATRIX).xyz;\n$else\n\ttexcoords_3d = VERTEX;\n$fi\n}\n\nvoid fragment() {\n\tfloat _seed_variation_ = 0.0;\n$begin_generate\n\tALBEDO = $albedo_color.rgb*$albedo_tex(vec4(texcoords_3d, 0.0));\n\tMETALLIC = $metallic*$metallic_tex(vec4(texcoords_3d, 0.0));\n\tROUGHNESS = $roughness*$roughness_tex(vec4(texcoords_3d, 0.0));\n\tSPECULAR = 0.5;\n\tEMISSION = $emission_energy*$emission_tex(vec4(texcoords_3d, 0.0));\n\tAO = $ao_tex(vec4(texcoords_3d, 0.0));\n\tAO_LIGHT_AFFECT = $ao;\n$end_generate\n}\n"
},
"type": "material_export"
}