Coder Social home page Coder Social logo

Comments (8)

Theverat avatar Theverat commented on May 19, 2024

Maybe we can add a "save to disk" feature to DefineBlenderMesh in pyluxcoreforblender.

from blendluxcore.

Dade916 avatar Dade916 commented on May 19, 2024

With the introduction of Serialization, the code for saving any type of mesh is already available. I can expose this feature to save a single Mesh. Something like Scene::SaveMesh(meshName).

from blendluxcore.

Theverat avatar Theverat commented on May 19, 2024

That would be great.
I'm still thinking about some possible ways to do the caching.

One option would be to keep a single luxcore_scene alive the whole time Blender runs and only update it when a viewport or final render is started.
However I have the feeling I would open a whole can full of possible bugs with this approach.

So I think the more safe variant is to have a Scene::SaveMesh like you said and save the meshes to a temp file when the RenderEngine instance is deleted (i.e. the luxcore_session is stopped and deleted).
I only want to save to disk at the end of a session because otherwise we get a lot of write operations when someone for example sculpts a mesh or adjusts modifier settings while the viewport render is running.

The temp file handling would be done by a class similar to the current image cache:
https://github.com/LuxCoreRender/BlendLuxCore/blob/master/export/image.py
And all temp meshes would be deleted when Blender is closed.

from blendluxcore.

Dade916 avatar Dade916 commented on May 19, 2024

You seem to work under the assumption that loading a mesh from file is faster then defining a mesh from memory. This i not true since the introduction of DefineBlenderMesh(). I'm pretty sure that the execution time of DefineBlenderMesh() is smaller than some Scene::LoadMesh().

So, I assume, the source of the problem is in some transformation of Blender mesh prior of DefineBlenderMesh() call. Like for instance, splitting the mesh according the materials used. The solution would be to link Blender mesh with multiple LuxCore meshes saved on files. In order to not just skip DefineBlenderMesh() but all the Blender mesh pre-processing phase. Is this correct ? Can you point me to the "incriminated" code ?

In this case, a possible solution would be also to accelerate all the pre-process phase in C++ (not just DefineBlenderMesh()) but it would be far more complex than a Scene::SaveMesh() and it is something I would like to avoid.

from blendluxcore.

Theverat avatar Theverat commented on May 19, 2024

So, I assume, the source of the problem is in some transformation of Blender mesh prior of DefineBlenderMesh() call.

Yes. The problem is the blender_obj.to_mesh() method.
https://github.com/LuxCoreRender/BlendLuxCore/blob/master/export/blender_object.py#L29
It is very fast when there are no modifiers on the object, but when there are modifiers, it has to evaluate all of them obviously.
And we can't really replicated this as we would have to implement all Blender modifiers. And it would probably not even be faster since blender already does this in C code.

I guess I will not even cache meshes without modifiers because of the reason you mentioned.
The loading from disk is purely there to skip the to_mesh method.

from blendluxcore.

Dade916 avatar Dade916 commented on May 19, 2024

Ahah, Scene::SaveMesh() is already available in LuxCore (and I assume it was used by LuxBlend).

I extended the code to so .bpy file format (i.e. serialized mesh) can be used in any place where it was possible to use only a .ply file before.
So the file extension drives the file format used to save or the one expected when loading.

from blendluxcore.

Theverat avatar Theverat commented on May 19, 2024

It was made available for this purpose, but I never came around to use it.

from blendluxcore.

Theverat avatar Theverat commented on May 19, 2024

I implemented a disk based mesh cache, but it is slower than to_mesh and DefineBlenderMesh.
So I pushed it into a branch for future reference and I don't intend to merge it into master.
https://github.com/LuxCoreRender/BlendLuxCore/tree/mesh_disk_cache

The original goal of this issue (preventing the re-export of a mesh when only the object is transformed) was implemented in this commit in master: 75f7655

from blendluxcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.