diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-08-18 17:40:04 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-08-18 18:08:23 +0300 |
commit | 036f43f3cde472867de87032297d74390aa2815e (patch) | |
tree | 034a8be0f6ea860aba04f48133d93893c6b8dd62 /source/blender/blenloader | |
parent | e8f0ee157b290e41258bf704d63c00cb2d4d2a90 (diff) |
Eevee: Convert metallic nodes into princinpled nodes
And wipe metallic out of the map.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 76 |
1 files changed, 50 insertions, 26 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ce452d58565..810bf5a3a46 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -433,37 +433,61 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) } { - { - /* Eevee shader nodes renamed because of the output node system. - * Note that a new output node is not being added here, because it would be overkill - * to handle this case in lib_verify_nodetree. */ - bool error = false; - FOREACH_NODETREE(main, ntree, id) { - if (ntree->type == NTREE_SHADER) { - for (bNode *node = ntree->nodes.first; node; node = node->next) { - if (node->type == SH_NODE_EEVEE_METALLIC && STREQ(node->idname, "ShaderNodeOutputMetallic")) { - BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); - error = true; - } + typedef enum eNTreeDoVersionErrors { + NTREE_DOVERSION_NO_ERROR = 0, + NTREE_DOVERSION_NEED_OUTPUT = (1 << 0), + NTREE_DOVERSION_TRANSPARENCY_EMISSION = (1 << 1), + } eNTreeDoVersionErrors; + + /* Eevee shader nodes renamed because of the output node system. + * Note that a new output node is not being added here, because it would be overkill + * to handle this case in lib_verify_nodetree. + * + * Also, metallic node is now unified into the principled node. */ + eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR; + + FOREACH_NODETREE(main, ntree, id) { + if (ntree->type == NTREE_SHADER) { + for (bNode *node = ntree->nodes.first; node; node = node->next) { + if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && + STREQ(node->idname, "ShaderNodeOutputMetallic")) + { + BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); + error |= NTREE_DOVERSION_NEED_OUTPUT; + } - else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { - BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); - error = true; - } + else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { + BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); + error |= NTREE_DOVERSION_NEED_OUTPUT; + } - else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ && - STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) - { - node->type = SH_NODE_OUTPUT_MATERIAL; - BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); - } + else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ && + STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) + { + node->type = SH_NODE_OUTPUT_MATERIAL; + BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); + } + + else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && + STREQ(node->idname, "ShaderNodeEeveeMetallic")) + { + node->type = SH_NODE_BSDF_PRINCIPLED; + BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname)); + node->custom1 = SHD_GLOSSY_MULTI_GGX; + error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION; } } - } FOREACH_NODETREE_END - if (error) { - BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); - printf("You need to connect Eevee Metallic and Specular shader nodes to new material output nodes.\n"); } + } FOREACH_NODETREE_END + + if (error & NTREE_DOVERSION_NEED_OUTPUT) { + BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); + printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n"); + } + + if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) { + BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); + printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n"); } } } |