Luxcore nodes from file

Discussion related to the Engine functionality, implementations and API.
Post Reply
wasd
Posts: 109
Joined: Tue Apr 24, 2018 7:20 pm

Luxcore nodes from file

Post by wasd » Wed Sep 12, 2018 1:45 pm

B.Y.O.B. wrote:
Wed Sep 12, 2018 12:24 pm
It would be relatively easy to create a "material from file node", it can be done with beginner-level python skills.
If you want to implement this, feel free to ask me for a more detailed explanation on how to do this.
But since this is a very niche request I won't implement it myself (I doubt many people want to write their materials this way).
I think everyone would love to write their materials this way! Because Blender has no convenient way to write them. But that's only my opinion.
To the point: I have trouble converting nodes to string.

If bpy.data.node_groups['my_material'] is the right object to save? If so, then it should be "serialized' or something like this. But it should be supported by actual class if I get it right, and bpy.struct don't want to help me. In short: pickle says it won't just pickle my_material.luxcore.node_tree.
CPU Bidir + Metropolis | Log Power | Core i5-4570

User avatar
Dade
Developer
Posts: 1538
Joined: Mon Dec 04, 2017 8:36 pm

Re: Luxcore nodes from file

Post by Dade » Wed Sep 12, 2018 1:54 pm

The problem is a bit more complex than it may look at first sight because a material can reference other materials, a material can reference other textures, textures can reference other textures and textures can reference external files.

So saving a material can require a cascade of other save operations. This probably require to support the material-save operation at LuxCore API level because it may be to complex to implement otherwise.

It could be done using serialization in order to generate a single self-contained file (like resume rendering file). But this solution has the problem of binary file format beings LuxCore version specific (i.e the compatibility can be broken with new versions).

Otherwise it could be done as a text properties file including every materials/textures but the external files (like image maps, etc.).
Support LuxCoreRender project with salts and bounties

wasd
Posts: 109
Joined: Tue Apr 24, 2018 7:20 pm

Re: Luxcore nodes from file

Post by wasd » Wed Sep 12, 2018 2:09 pm

Dade wrote:
Wed Sep 12, 2018 1:54 pm
It could be done using serialization in order to generate a single self-contained file (like resume rendering file). But this solution has the problem of binary file format beings LuxCore version specific (i.e the compatibility can be broken with new versions).

Otherwise it could be done as a text properties file including every materials/textures but the external files (like image maps, etc.).
Yep. I thought of easy way to dump material, to make some proof-of-concept code. Now I see, that if there's no easy way to serialize material object, there's no point in doing it not so easy way.

Question: is there any text format definition for luxcore nodes? If not I'll just write something.
CPU Bidir + Metropolis | Log Power | Core i5-4570

User avatar
B.Y.O.B.
Developer
Posts: 1825
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Luxcore nodes from file

Post by B.Y.O.B. » Wed Sep 12, 2018 2:22 pm

wasd wrote:
Wed Sep 12, 2018 1:45 pm
I think everyone would love to write their materials this way! Because Blender has no convenient way to write them. But that's only my opinion.
To the point: I have trouble converting nodes to string.
I think we are misunderstanding each other.
I thought you want to write your materials as text files, by hand, like this one: https://github.com/LuxCoreRender/LuxCor ... un.scn#L11

But you seem to want to create them as Blender nodes, then save them as text (with ability to load back into nodes)?
And you want this because of a bug that seems to happen where a .blend file is "corrupted" over time?
Wouldn't it be a better idea to find out what causes this bug and how to fix it?

Anyway, when you said you wanted to write luxcore materials as text files, I thought about something like this:
Attachments
Unbenannt.png
Unbenannt.png (11.49 KiB) Viewed 317 times
Support LuxCoreRender project with salts and bounties

wasd
Posts: 109
Joined: Tue Apr 24, 2018 7:20 pm

Re: Luxcore nodes from file

Post by wasd » Wed Sep 12, 2018 4:10 pm

B.Y.O.B. wrote:
Wed Sep 12, 2018 2:22 pm
But you seem to want to create them as Blender nodes, then save them as text (with ability to load back into nodes)?
And you want this because of a bug that seems to happen where a .blend file is "corrupted" over time?
Wouldn't it be a better idea to find out what causes this bug and how to fix it?

Anyway, when you said you wanted to write luxcore materials as text files, I thought about something like this:
It's not that exactly of this bug. I just don't want to deal with blender's link feature. I want my luxcore material library as files. Yes, create them as nodes, dump to files, then reuse.

I have some uncertain suspicion, that roots of blend file corruption bug lie within node with addon interaction bug. Or elsewhere within blender api.

The better way will be integrated in blender material library feature. Linking material from file looks to me like some ugly hack. Besides, it has its other ugly downsides. This whole linking feature, it is poorly implemented from my point of view.
CPU Bidir + Metropolis | Log Power | Core i5-4570

User avatar
B.Y.O.B.
Developer
Posts: 1825
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Luxcore nodes from file

Post by B.Y.O.B. » Wed Sep 12, 2018 6:20 pm

Have you tested Blender 2.8? I think one of the goals was to improve asset management.
Support LuxCoreRender project with salts and bounties

Post Reply