Jump to content
3DCoat Forums

3dcoat PBR to Blender Principled BSDF Add-On


Haunted
 Share

Recommended Posts

  • Member

Hi,

I wrote a Blender Add-On to import materials exported from 3D Coat into Blender using the new Principled BSDF shader. ^_^

Help me test it

I updated the script to V 0.7

I just updated the script to V 0.7, it now supports Eevee in Blender V 2.8 (Blender Dev build, can be found here: https://builder.blender.org/download/ )

I used Windows 64 bit (not the new compiler one). I guess it should work with any of these. Since Blender 2.8 is still in development, I can't guarantee the Add-on to be working forever.

Add-on download link: https://irrgeist.de/blender-3d-coat-pbr-import-add-on/

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Changes:

  • Metallic now connects to the correct slot
  • Metttalic, Roughness and NMap are now set to Non-Color
  • If AppLink is present, new toolbar option available (WIP, not working for now)

It should now find .tga, .png and .bmp files. Make sure to give each map the same extension in 3D Coat. Don't mix it :)

How to install

Copy the script content and paste it into a new file, named '3dCoatPBRImporter.py'

In Blender:

  • Open File
  • User Preferences ...
  • Open the "Add-ons" tab
  • Click on the "Install Add-on from File..." button at the bottom
  • Choose the .py file
  • Activate the newly added plugin (filter for 'coat' if you can't find it)

How to use

Export your model from 3D Coat like so:

  • 'File' => 'Export Objects & Textures
  • Check the following ONLY (and select the Blender Export Preset):
    • Export Color
    • Export Roughness
    • Export Metalness
    • Export Tangent Normal Map
    • ExportAO
    • ExportCurvature

 

Screenshot:

settings.PNG.14c532a090bacbc6b34e5f1c734cc9e9.PNG

 

Make sure you use Cycles Renderer

 

After installation you will find a new menu entry under 'File' => 'Import' => '3D Coat PBR material

First select your object(s) you want to import the new material to.

Then click the new menu entry. This will open a file explorer in Blender. Select the .OBJ or .FBX file. If all your textures/maps are in the same folder as your model (it should be, by default), then the plugin will create a new material for your selected object(s).

 

That's it. It's beta. Let me know if you encounter any bugs. If so, post your Blender Console output here (Window => Toggle System Console => Execute the Add-on => mark all text in the console and RIGHT click to copy)

Thanks to digman for the advice on how to setup the nodes.

Regards,

Haunted

 

P.S. Updates will be posted in this thread. If there's a need and it seems to be stable, I will commit the Add-On to the official Blender Add-on page.

 

  • Like 2
Link to comment
Share on other sites

  • Reputable Contributor

Thanks again for the Blender PBR addon.

Installed addon, shows no problems with it in the preferences panel in Blender after closing  Blender and reopening

Cycles Renderer is selected.

1. I first import the obj model.

2. make sure it is selected.

3. File menu / Import/ 3D Coat Pbr material.

4. Select the same model, textures are in the same folder.

5. A new Material is created plus the Pbr principled shader created but no maps are loaded.

I think it is a possible naming convention problem of the maps. 

I did not know at first you were creating a Blender addon. There is no choice in naming your maps using the more simple Blender cycles settings in 3DC. They have longer names.

I made a export constructor preset. Looked at your Blender python script to see if I could get the naming convention correctly. No luck and I tried a few naming conventions.

Can you show the proper names of the maps that 3DC needs to export. I can test to see if the problem is fixed.

In this case it might require the use of a making an export constructor preset for the Addon. 

I will wait for your reply.

Picture shows what the console saids.

naming.PNG

Edited by digman
Link to comment
Share on other sites

  • Carlosan changed the title to 3dcoat PBR to Blender Principled BSDF Add-On
  • Member

Hi, thank you for testing :)

The Add-ons searches for the files with this pattern:

[MODEL NAME]_[UV NAME]_[TYPE].tga
e.g.:
mymodel_someFancyUV_color.tga
mymodel_someFancyUV_metalness.tga
mymodel_someFancyUV_rough.tga
mymodel_someFancyUV_nmap.tga

The UV name shouldn't matter and atm it must be TGA. I will add an option to choose the file type or make the script autodetect the correct extension in the next release.

Can you post the names of your generated files? I guess it's something like:

torus1_torus1_auv_color.PNG? and so on...

I totally forgot to mention that. Unfortunately I can't edit my first post anymore :(

Edited by Haunted
Link to comment
Share on other sites

  • Member

I updated the script to V 0.1.2

Download:  https://pastebin.com/RjC7ngHH

It should now find .tga, .png and .bmp files. Make sure to give each map the same extension in 3D Coat. Don't mix it :)

Edited by Haunted
  • Like 1
Link to comment
Share on other sites

  • Reputable Contributor

Would it be possible to integrate this with the current Blender Applink? You could sell it as an updated Blender Applink on Gumroad or BlenderMarket. I'd be one of the first in line.

The Applink for 3ds Max works really well. You can choose a render preset in the Max side of the Applink (ie. iRay, Mental Ray, VRay) and when exporting a model from 3D Coat to Max, you go to FILE > EXPORT TO > 3ds Max 20xx and it sends the model to Max and loads it into the scene with the materials all hooked up and ready to render. Something like this would be AWESOME for Blender. Maybe an AMD ProRender preset, but just Cycles for now.

 

Link to comment
Share on other sites

  • Member

Hey,

just tried the latest AppLink for Blender, seems to be broken with 2.79. I can import the Mesh but that's it. Clicking on "Transfer" gives me a syntax error. 

Is it normal, that I have to Select "File => Export => Blender" in 3D Coat and manually find my Export Folder? Or am I doing it wrong? 

When I find the time, I will look into the existing AppLink code and try to enhance it. I just need to figure out what these option were supposed to do:

applink.jpg.8169ef3b75a3bea9104f0498173a7432.jpg

Link to comment
Share on other sites

  • Reputable Contributor

I will test again, later today or tomorrow the new script.  

I do not mind the current way of how the plug-in works. Yes you have to import the model into Blender first, but a simple plug-in is less likely to get broken.

I would suggest keep the current method but investigate the 3DC to Blender applinks, there are two by the way... 

Link to comment
Share on other sites

  • Reputable Contributor

Found a few minutes to test.

I set up a 3DC export constructor preset according to the naming convention you showed in the picture. The maps now load.  EDIT:  The eport constructor is broken for Blender cycles use the simple one, works since you update the script.

You still have a few errors in your setup.

Metallic, Roughness and Normal maps need to be set to Non_Color_Data for the PBR Principled Shader to read them properly as stated in my earlier postings. This is a must for the correct rendering of these maps. Click on the drop down arrow and you will see Non_Color_Data in the list.

The Image Texture node (Metallic) needs to be inputed into the Metallic slot on the Shader not Specular.  Specular is used for artistic purposes mainly.  The current setup will render the metallic map incorrectly.

Thank you again for working on the plug-in.

 

 

corrections_04.png

Edited by digman
  • Like 1
Link to comment
Share on other sites

  • Reputable Contributor

Here is a correct rendering when all is setup correctly in 3DC and Blender. It is pretty close with only some minor tweaking. I used the same Hdr image for both 3DC and Blender. No added lights in Blender only the hdr image.

This is a manual setup not the plug-in.

In the second picture is the correct setup for 3DC to Blender. Setting up correct GGX shader,  Texture Export / Import Workflow and the export panel. 

The export constructor for Blender Cycles is indeed broken. Since you updated the script the simple one is the one to use. 

I did not rename the nodes in the picture it is just to demonstrate.

 

Correct.PNG

3DC.PNG

Edited by digman
  • Like 1
Link to comment
Share on other sites

  • Reputable Contributor

This goes with the last 2 above postings... I am not being critical just pointing out what needs to be changed for your plug-in to work.

The plug -in result at it's imported settings compared to the settings for correct rendering.

plug-in.PNG

Edited by digman
  • Like 1
Link to comment
Share on other sites

  • Reputable Contributor

By the way, Haunted, thank you for taking the time to look into this. An Applink that can export a model that either originates in 3D Coat (via the FILE menu > EXPORT TO > Blender), or that came from Blender > modified in 3D Coat, and have the materials setup (via a Principled Shader) to being rendering in Cycles or Evee, is sorely needed.

If a model has a lot of individual parts and UV maps, it's a bit of a hassle to have to go and hookup all the nodes to their associated maps. This plugin could save a lot of setup time and make create a nice workflow between the apps. You can contact Andrew (support@3dcoat.com) for help working with the applink. He might even contract you to do so, although I think the best thing would be to setup a Gumroad page or offer it on BlenderMarket. You deserve to be compensated for your efforts, and for filling a need. The applink has never exported materials over, to use for Cycles.

  • Like 1
Link to comment
Share on other sites

  • Member

Hi you two :)

@digman

Thank you very much digman for taking your time to test and optimise the materials! Now THAT looks waaay better. I may have been drinking too much Jägermeister that day. Of course the metallic needs to be connected to the metallic slot :rofl: I totally overlooked the non-color thing. I changed both problems and updated the script (see end of post)

@AbnRanger

Thank you very much. I can see the need for the AppLink update, that's the reason why I even started doing this :D I am investigating the existing AppLink(s) now (SimpleAppLink depends on the original). I am trying to alter my script, so that it will use the existing functionality. I got the AppLink running, but "Import" doesn't seem to work for me. Also I first have to use the "tranfer" button of the "old" AppLink" for the "Simple3DCoat AppLink"'s "Export" to work.

Does the AppLink work for you (except the material stuff)? If so, how is your workflow?

Since I have many other things in my pipeline, I will not be able to update the old AppLink scripts (they are rather big and complex and lack comments). But I will try to make it look like this:

3dCoatPBR.JPG.0a5911f0e9b728ddd56315af653c381b.JPG

My script will hopefully offer these things:

  1. The already implemented Import (does NOT need AppLink)
  2. The Import/Export Buttons in the Blender Toolbar to Update the material based on the AppLink imported data (hope it will work)
  3. Will be free, I don't plan to make money with it, I am having fun :)

So here's the latest Version:

I updated the script to V 0.1.5

Download:  https://pastebin.com/3fgYwsNc

If AppLink Add-on is activated, you should already see the new buttons in the EX-Toolbar. But they to not work yet. If disabled, there should be no toolbar extension at all. In the next version :P

Changes:

  • Metallic now connects to the correct slot
  • Metttalic, Roughness and NMap are now set to Non-Color
  • If AppLink is present, new toolbar option available (WIP, not working for now)

 

 

Edited by Haunted
Link to comment
Share on other sites

  • Member

I just finished setting up my blog and made a post about this Add-on here:

https://irrgeist.de/2018/02/18/blender-3d-coat-pbr-material-add-on/

I will update the source files and infos there, so maybe the forum "update ghost" can put the link in my first post :) I will also post here, when updates are made.

Link to comment
Share on other sites

  • Reputable Contributor

Success, the plug-in is now functioning... 

A couple of tips, that has nothing to do with the plug-in.

1. Rename your mtl file, that way no textures maps are loaded on the initial importing of the model. I just add the letter "X" in front of the mtl file name. Blender reads the mtl file and load the maps though not set up correctly of course.  This is for 3DC exporting.

The reason is that the plug-in will also import the maps and you will have a double set of textures in the drop down menu of the texture nodes.

The above is not necessary, it will not effect the correct rendering, it is just more efficient...

In 3DC hide the AO layer otherwise it will be included in the albedo map which will give light information to the albedo map. Does not effect the exporting of the AO map, it will still export the map if set up to do so in the export settings. Of course you can leave the AO in the albedo map if artistically it helps..

For new users of Blender. Under the Material tab, use the drop down arrow to select the new plug-in created material to activate it. Shown in picture.

Funny, I noticed the Mtl file does not include the metalness map. I will bring that up in the beta forum and about the broken Blender cycles export constructor, it exports the wrong kind of maps.

Also for new users of Blender to get the same lighting on your model in Blender, use the same hdri as in 3DC. This is again not necessary as you might want a different hdri map. Having the same maps is a way of comparing between what you see in Blender and what you see in 3DC.

Goodtogo.PNG

material.PNG

Edited by digman
  • Like 1
Link to comment
Share on other sites

  • Member
9 minutes ago, digman said:

Success, the plug-in is now functioning... 

Very good :D Thanks again for testing and the tips!

I will keep you up to date with the progress of the AppLink integration and future updates. I was thinking about adding some sliders to the nodes to quickly adjust the amount of roughness and metalness, what do you think?

Oh, and next will be Eevee I guess ... didn't check it out that much. But I guess the setup will be similar. Hope the Python SDK is not that different in this version.

Edited by Haunted
Link to comment
Share on other sites

  • Reputable Contributor

In the textures nodes themselves? or through the use of other nodes as shown in the picture. Either way would be very helpful.

I found this setup better at fine control that just using the brightness / contrast node and the RGB to BW node.

Since the RGB to BW node converts the RGB Curves node information back to a "Value" input, that should set it back to Non_Color_Data which the 2 maps need for correct rendering. You can see in the node that the output is Val or value (gray sphere in the node) hooking to the value node (gray sphere) in the principled shader.

I though will have to make sure that information is correct though it does appear to function correctly.

 

notknow.PNG

Edited by digman
  • Like 1
Link to comment
Share on other sites

  • Reputable Contributor

It appears correct. If you do not mind experimenting a little here, go ahead and create the script. 

Having a node group, I like and can be expanded if necessary or ungrouped.

Edited by digman
Link to comment
Share on other sites

  • Member

Just updated to V 0.6 and included the RGB stuff. Setting up a group was a pain in the ass, so I stopped working on that (for now maybe).

Download is here (always latest Version):

https://irrgeist.de/blender-3d-coat-pbr-import-add-on/

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • Reputable Contributor

No problem at all, This will be straight forward to use this way... The main thing is we have a plug-in where we do not have to set up all the nodes each time or append a group from another file. 

Test sometime today..

Edit: Looks good, renders correctly. Thanks for adding the adjustment node setup, it easy to tweak the roughness and metallness map and not have to do it externally.

Real time feedback in Blender for the adjusting. :good2: 

 

Edited by digman
more information
  • Like 1
Link to comment
Share on other sites

  • Reputable Contributor

Since your plug-in will be easy for users to setup and I think more people will start rendering in Cycles because of it, I include one node setup for transforming the Hdr image in Blender.

ADD / Input / Texture Coordinate node

ADD / Vector / Mapping node

move_hdr.PNG

Edited by digman
  • Like 2
Link to comment
Share on other sites

  • Member

Thank you very much digman for testing again ^_^

I will now begin tweaking some stuff and (finally) add Eevee support, AppLink integration and submit this plugin to Blender. But first I have to finish some other stuff in my pipeline. 

Your node setup for adding a HDR seems to be another good idea for a small plugin ;) "Choose HDR image" => Done 

 

Link to comment
Share on other sites

  • Member

Hi all, thanks for the nice words! :)

I just updated the script to V 0.7, it now supports Eevee in Blender V 2.8 (Blender Dev build, can be found here: https://builder.blender.org/download/ )

I used Windows 64 bit (not the new compiler one). I guess it should work with any of these. Since Blender 2.8 is still in development, I can't guarantee the Add-on to be working forever.

Add-on download link: https://irrgeist.de/blender-3d-coat-pbr-import-add-on/

Just for testing. Here's a a test Eevee render:

eevee.thumb.JPG.8e731dc459bf2a5e4449b22b569799ff.JPG

 

Some technical/tester stuff:

The Add-on now checks for the Blender version to switch between old and new API. I tested it with both versions without problems. If you encounter an error, toggle on the console in Blender: 

Window => Toggle System Console

and post a screenshot. This can help me find the bug :)

 

Edit:

If you want to import your .obj with Blender 2.8 it will not work (for me at least). If you encounter the same problem, just import it with Blender 2.7 and save the .blend file. then open it with Blender 2.8 ;) 

Edited by Haunted
Corrected wording @ Download link
  • Thanks 1
Link to comment
Share on other sites

  • Member

Someone deleted the download link of the first post hehe :D Guess it was mistaken with the Blender Dev Build link I also posted. I added the download link to my last post.

Link to comment
Share on other sites

  • Reputable Contributor

quote "If you want to import your .obj with Blender 2.8 it will not work (for me at least). If you encounter the same problem, just import it with Blender 2.7 and save the .blend file. then open it with Blender 2.8 "

LOL, I found that out too. Why can I not import models into 2.8. Did some googling and found the same answer you did. It is just the current state of development I believe for 2.8, my guess that is... 

Thanks for the Eevee render plug in too, test sometime over the weekend.

Edited by digman
  • Like 1
Link to comment
Share on other sites

  • Member
4 minutes ago, digman said:

quote "If you want to import your .obj with Blender 2.8 it will not work (for me at least). If you encounter the same problem, just import it with Blender 2.7 and save the .blend file. then open it with Blender 2.8 "

LOL, I found that out too. Why can I not import models into 2.8. Did some googling and found the same answer you did. It is just the current state of development I believe for 2.8, my guess that is... 

Thanks for the Eevee render plug in too, test sometime over the weekend.

Yeah lol,

they changed a lot in the internal handling of scenes and layers and so on and I guess they did not update the Python binding so the import script produces an error at the moment :D.

Also interesting: https://code.blender.org/2016/12/the-blender-101-project-and-you/

Edit: And with the Blender Code Quest they are now trying to push the development and finish 2.8 until mid 2018 :D I just bought one of their rockets to support them: https://www.blender.org/2-8/quest/

 

Edited by Haunted
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...