Working on a Blender (collada) export, need some help


Working on a Blender (collada) export, need some help
#1
Hello all.

Orion pointed my to the Collada format in this thread:
https://forums.ldraw.org/thread-23915-po...l#pid36135

Couple of hours later I had a very basic highly experimental export for it in LDCad opening many exiting possibilities for using LDraw content inside blender.

But my lack of Blender experience is a bit of slowdown.

I would really appropriate some help in setting up some basic materials to use on the LDraw meshes/objects.

Can anyone share some pointers on this ?

A basic LEGO like plastic and rubber would be a great starter.
Reply
RE: Working on a Blender (collada) export, need some help
#2
Maybe get in contact with the Mecabricks folks? They already have a working export and I'd love to see a closer collaboration between us and them.
Reply
RE: Working on a Blender (collada) export, need some help
#3
(2020-02-29, 20:49)Orion Pobursky Wrote: Maybe get in contact with the Mecabricks folks? They already have a working export and I'd love to see a closer collaboration between us and them.

Might be an idea, but they use a custom written blender plugin,

I really prefer to generate a single/some stand alone file(s) just like with the pov-ray export.


The one big problem I'm running into at the moment is that Blender doesn't really import the materials defined in the collada file, it seem to only use the given names.

So you'll have to edit all (unique) materials after an import by hand.

I'm looking into the possibility to link to the blender material library instead.

You could also solve this with a small plugin/macro which replaces the materials after import, but like I said I rather have it all standalone Angry
Reply
RE: Working on a Blender (collada) export, need some help
#4
Some progress
   

But I had to 'color' it manually inside blender.

For this you select a random brick of color x and edit its material, it will then change all bricks using that same color.

I'm also not sure how to handle the recursive nature of LDraw, how would one organize 'collections' etc inside Blender to get the model submodel feel of things?

It now generates this:
   

Again some pointers from experienced blender users would be highly appreciated.
Reply
RE: Working on a Blender (collada) export, need some help
#5
Some more progress, this is how it now renders 'out-of-the-box':
   

Turned out the missing material was due to a typo in some ID tag Big Grin

It now only seem to ignore the alpha channel in the diffuse value.

Also something weird is going on with the material binding as it sometimes attaches to the mesh while it should always be attached to the node object.
   

Anyone has a clue on why that could happen, all the refs are defined in a loop and thus exactly the same except for some names and matrices and there is nothing special/different about the parts referenced ether.
Reply
RE: Working on a Blender (collada) export, need some help
#6
(2020-03-01, 2:11)Roland Melkert Wrote: Some more progress, this is how it now renders 'out-of-the-box':


Turned out the missing material was due to a typo in some ID tag Big Grin

It now only seem to ignore the alpha channel in the diffuse value.

Also something weird is going on with the material binding as it sometimes attaches to the mesh while it should always be attached to the node object.


Anyone has a clue on why that could happen, all the refs are defined in a loop and thus exactly the same except for some names and matrices and there is nothing special/different about the parts referenced ether.

Hi Roland - I started with Toby Nelson’s LDraw Blender importer and created an additional module to automate the render. I modified the importer to enable common LDraw capabilities like supporting multiple search paths, importing an archive library etc... The addon can be used by any application using the out of the box Blender API/addon calls. You can see full details at my GitHub repo repo. I believe working directly with the LDraw format is optimal.

   

Cheers,
Reply
RE: Working on a Blender (collada) export, need some help
#7
(2020-03-01, 13:07)Trevor Sandy Wrote: Hi Roland - I started with Toby Nelson’s LDraw Blender importer and created an additional module to automate the render. I modified the importer to enable common LDraw capabilities like supporting multiple search paths, importing an archive library etc... The addon can be used by any application using the out of the box Blender API/addon calls. You can see full details at my GitHub repo repo. I believe working directly with the LDraw format is optimal.
Seems very interesting, I'll take a look at it.

I'm still hoping to setup something universal though as my goal is to be able to export animations with the promise of Blender's faster (then povray) rendering at similar or better quality.

Export is the easiest to do this with as the LDCad internals know exactly how to process LDraw and animation scripts already.
Reply
RE: Working on a Blender (collada) export, need some help
#8
Another update on my progress

It now handles MPD, transparency and fake seams.

   



I also seem to have indirectly solved the material binding problem as a result of using a different approach which was needed to preserve the LDraw recursion (submodels) inside the export file.



Lighting is still a bit overexposed haven't really played with lighting in blender nor the collada file itself.

Still need a lot of tweaks and cleanup as the whole process is still very fragile (e.g. mpd's using embedded parts won't export correctly).

I'm still hoping to find someone willing to help me with the collada materials etc.
Reply
RE: Working on a Blender (collada) export, need some help
#9
(2020-03-02, 1:41)Roland Melkert Wrote: I'm still hoping to find someone willing to help me with the collada materials etc.

Unfortunately I think you'd get better luck in a Blender focused forum or a larger AFOL community forum.
Reply
RE: Working on a Blender (collada) export, need some help
#10
(2020-03-02, 1:47)Orion Pobursky Wrote: Unfortunately I think you'd get better luck in a Blender focused forum or a larger AFOL community forum.

Hello, I am the Mecabricks guy Wink
If you want to get in touch with me, I could answer your Blender questions I saw in this thread. However, I can already tell you that if you want to get photorealistic results, you will have to write your own addon for Blender in order to build your specialised materials for the built in renderers (Cycles/Eevee). Generic formats like collada can only output generic materials. In the case of Blender, it is basically the principled shader with default settings. Besides as you already found out, you do not have a great control over how material and mesh data are structured which has a great impact on the render time and memory used.
Reply
RE: Working on a Blender (collada) export, need some help
#11
(2020-03-04, 10:39)Nicolas Wrote: Hello, I am the Mecabricks guy Wink
If you want to get in touch with me, I could answer your Blender questions I saw in this thread. However, I can already tell you that if you want to get photorealistic results, you will have to write your own addon for Blender in order to build your specialised materials for the built in renderers (Cycles/Eevee). Generic formats like collada can only output generic materials. In the case of Blender, it is basically the principled shader with default settings. Besides as you already found out, you do not have a great control over how material and mesh data are structured which has a great impact on the render time and memory used.

Thanks,

I already discovered some major downsides to the collada format and especially how Blender imports them (I suspect they don't fully follow the spec on some things).

But all in all I'm quite happy with the result it gives, I love that default 'milky' look cycles generates even with the default materials.

The main reason I hope to avoid writing a blender plugin is it would mean I have to basically rewrite the animation interpretation code in python.

I'm considering a small plugin which would post process the materials and lighting though, I would like some pointers on that some day if you don't mind.
Reply
RE: Working on a Blender (collada) export, need some help
#12
(2020-03-04, 19:59)Roland Melkert Wrote: I'm considering a small plugin which would post process the materials.

Yes, this shall really be on top of your to do list once you are happy about how your meshes import as this is the whole purpose of using a ray tracing software. Also make sure that materials are linked to meshes, not objects. This means that you can only use the same mesh with the same material. Using the same mesh instance with multiple materials (by linking the material to the object instead of the mesh) seems to be a good idea but is actually not (most 3D software actually don't even support this option). See the instances options in the Mecabricks Collada exporter.
Reply
RE: Working on a Blender (collada) export, need some help
#13
(2020-03-04, 20:25)Nicolas Wrote: Using the same mesh instance with multiple materials (by linking the material to the object instead of the mesh) seems to be a good idea but is actually not (most 3D software actually don't even support this option).

Yes I discovered that the hard way.

I'm now generating all material-part combinations as nodes in the library_nodes branch.

And then reference those using instance_node elements in the scene branch.

This seems to work the best, except sometimes Blender decides a node in the library branch is a standalone object and adds it separately to the scene without any unit corrections or scaling.

I'm close on pinpointing why that happens though.
Reply
RE: Working on a Blender (collada) export, need some help
#14
Maybe RenderMan could be interesting too? See https://www.eurobricks.com/forum/index.p...nt-3206590


Quote:
Quote:12 hours ago, supertruper1988 said:
Any reason to go thru all this for the outdated and unsupported LEGO Digital Designer vs an open format like LDraw or the supported Studio?
It’s open source. So if you prefer any of these formats feel free to create a fork or add pull requests to add that functions.
Reply
RE: Working on a Blender (collada) export, need some help
#15
Update....

I've been working on the new export off and on again and decided to concentrate on geometry and animation data and leave the material side of things as they are.

I've also started a second exporter for the glTF2 format as it seems to have a much better support in Blender (and the 3D community as a whole).

glTF2 is easy to generate but seems to have only limited animation support.

On the plus-side I already managed to export glTF2 files including a simple (static) test animation. Blender accepts the file but the animation possibilities of glTF2 seem to be very limited.

   

Collada on the other end has very extensive animation support but I'm not sure Blender would actually import it all. 

In short I'm looking for some advise/thoughts on these issues, or maybe recommendations on a third format ?

I would also appreciate some collada animation test files if any one knows where to get them?

Attached is a glTF2 test export for the 5510.mpd example, any comments and feedback is welcome. (I removed the attachment, it's outdated).
Reply
RE: Working on a Blender (collada) export, need some help
#16
Another update....

I finished basic glTF export, including animations. Animations are limited to include only object position and orientation as that's the only thing the glTF2 format allows (besides scaling).

Did a small render test, took cycles 15 minutes, which gave me the attached gif. I attached it as a zip as 1MB gif's are too large to attach as is.


I'm still not sure if collada would offer more animation possibilities, I might even drop collada from 1.7 as glTF2 seems to be enough (for now).


Attached Files
.zip   8860.zip (Size: 956.8 KB / Downloads: 8)
Reply
RE: Working on a Blender (collada) export, need some help
#17
(2020-04-25, 2:06)Roland Melkert Wrote: Another update....

I finished basic glTF export, including animations. Animations are limited to include only object position and orientation as that's the only thing the glTF2 format allows (besides scaling).

Did a small render test, took cycles 15 minutes, which gave me the attached gif. I attached it as a zip as 1MB gif's are too large to attach as is.


I'm still not sure if collada would offer more animation possibilities, I might even drop collada from 1.7 as glTF2 seems to be enough (for now).

Awesome man. LDCad animation is on my list of things to learn.
Reply
RE: Working on a Blender (collada) export, need some help
#18
Nice!!!

(2020-04-25, 2:06)Roland Melkert Wrote: Animations are limited to include only object position and orientation as that's the only thing the glTF2 format allows (besides scaling).
What else is missing, warped meshes?
Reply
RE: Working on a Blender (collada) export, need some help
#19
(2020-04-25, 7:31)Philippe Hurbain Wrote: What else is missing, warped meshes?

Object visibility, camera fov, active 'out' camera, light color, light enabled, material changes. All of these can be done in LDCad animations.

I could probably fake visibility by putting objects far away when they need to be hidden and material changes can also be done by having multiple meshes of which only one is visible at the time. But these kind of workarounds complicated the export process considerable.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)