cuddlyogre / ExportLDraw

LDraw Import and Exporter for Blender 2.82+
GNU General Public License v2.0
49 stars 12 forks source link

Materials do not export well #30

Open quacrobat opened 2 years ago

quacrobat commented 2 years ago

Hi, great work on this plugin, thank you.

One issue I found is when attempting to export imported LDraw models to glTF (using the default gltf importer/exporter), the colors/materials are not exported or at least are not read by any glTF viewer. According to the Blender glTF IO docs at https://docs.blender.org/manual/en/3.3/addons/import_export/scene_gltf2.html:

The core material system in glTF supports a metal/rough PBR workflow with the following channels of information:

Base Color Metallic Roughness Baked Ambient Occlusion Normal Map Emissive

and

Tip

Examining the result of the material import process is a good way to see examples of the types of material nodes and settings that can be exported to glTF.

Would you consider adding something like a "Convert to glTF compatible materials" toggle in import options?

Thanks :)

quacrobat commented 2 years ago

And what seems like a very useful video on the subject: Creating a glTF-compatible Blender material from a set of PBR textures https://www.youtube.com/watch?v=70LRKp54zIc

and a more detailed one here: Highlight: Making a glTF-compatible material from scratch in Blender https://www.youtube.com/watch?v=YFV33iCXXmo

quacrobat commented 1 year ago

hello, any way to fix this?

cuddlyogre commented 1 year ago

I'll start looking into this. Real life and other projects have kept me away.

cuddlyogre commented 1 year ago

After some cursory testing, it looks like it has something to do with the custom node groups that make up the materials. Exporting with a shader directly connected to output gives me that color, but using a node group gives me all grey.

I'll keep experimenting to find out for sure.

quacrobat commented 1 year ago

thanks for taking the time! happy holidays :)

On Wed, Dec 28, 2022, 05:04 cuddlyogre @.***> wrote:

After some cursory testing, it looks like it has something to do with the custom node groups that make up the materials. Exporting with a shader directly connected to output gives me that color, but using a node group gives me all grey.

I'll keep experimenting to find out for sure.

— Reply to this email directly, view it on GitHub https://github.com/cuddlyogre/ExportLDraw/issues/30#issuecomment-1366350699, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA673BLQ3AOTPG3QECUE74TWPO34LANCNFSM6AAAAAARACIGKY . You are receiving this because you authored the thread.Message ID: @.***>

quacrobat commented 1 year ago

After some cursory testing, it looks like it has something to do with the custom node groups that make up the materials. Exporting with a shader directly connected to output gives me that color, but using a node group gives me all grey.

I'll keep experimenting to find out for sure.

yes, perhaps the damage is already done at import time, when the LDraw colors are converted into node materials. An option toggle to import as an alternative node setup may be simpler than trying to change the nodes types at export time. What do you think?

cuddlyogre commented 1 year ago

After reading more, this isn’t an uncommon issue and it does appear my material setup is too complex for the exporter.

I’ll experiment with a way to simplify the node setup.

quacrobat commented 1 year ago

Happy New Year! Did you find time to look into this @cuddlyogre?

cuddlyogre commented 1 year ago

The only solution I could find is flattening the material node structure. I'm working on a dynamic programming solution so that I don't have to change the materials.

quacrobat commented 1 year ago

Hello, bump :)

cuddlyogre commented 1 year ago

I haven't forgotten. The different ways I could find to do it haven't really panned out. I'm still working on it though.

quacrobat commented 1 year ago

no worries, thanks for your quick reply!

quacrobat commented 10 months ago

Congrats on the new release! does it fix the materials export to gltf issue?

cuddlyogre commented 10 months ago

Unfortunately no. The gltf exporter doesn't seem to process anything but the principled bsdf shader, so it all still comes out grey. The best I could manage to export is the solid color with some shininess and some transparency. The end result isn't great, so I shelved it until maybe the gltf exporter improved, which is doesn't appear to have.

If you are only looking for basic colors and some specular and maybe transparency, it appears to be doable. If you're looking for materials with anything more than that, I don't think it's doable without having to do a lot of work by hand per part.

cuddlyogre commented 10 months ago

I was able to uv unwrap some parts using the sharp edges as a starting point. From there I baked a diffuse and normal texture and exported, set up a material to use them, and the visual results were pretty good. The origin of the object is at 0,0,0 though, so you'd need to sort that out if you're exporting a scene.

image

quacrobat commented 9 months ago

wow, that's a lot of work, thanks!