Supporting LuxCoreRender with Phantom Scatter

Discussion related to the LuxCore functionality, implementations and API.
Post Reply
User avatar
Phantom107
Posts: 9
Joined: Fri Nov 13, 2020 10:01 am

Supporting LuxCoreRender with Phantom Scatter

Post by Phantom107 »

HI friends,


Phantom Scatter introduction

I am the creator of Phantom Scatter, a standalone app that is designed around generating matrices used for the instancing of objects: https://scatter.phantomtechnology.nl/

The most effective use-cases are generating things like grass/forests. By keeping the instances out of your working model, it stays snappy and pleasant to work in. The scatter instances are only used in the final render, in the current case that is Octane Standalone.

Workflow looks like this:
instancing_support_fixed.jpg


Bringing support to LuxCoreRender

Now I'd like to bring support to LuxCoreRender. ;)

I read that it is possible here: https://luxcorerender.org/advanced-features/
Instances

When working on huge projects with multiple copies of the same object, LuxCoreRender’s support for instances will significantly save system resources, in particular memory consumption. If the same mesh is referenced by multiple objects, for example in the case of particles, it is only loaded into memory once.
Let's imagine we want to instance around grass pieces for an exterior scene, which is a totally common use-case. I don't see instancing in the SDL page (https://wiki.luxcorerender.org/LuxCore_ ... erogeneous)

A number of 100,000 grass pieces is easily reached. Am I understanding it correctly that I should now call a grass object 100,000 times inside the *.SCN file? I am hoping that if it's not yet supported, a feature can be developed where an object can reference a *.CSV file and then use those instance matrices, in the exact same format as is now requested by the scene.objects.<object name>.transformation call



Why instancing is of essential importance

Instancing tons and tons of objects makes renders truely come alive, making everything a bit different, varied, making it feel natural. Nothing in the real world is perfect, everything is a mess. By trying to create a mess in your renders, I believe it really enhances the quality and believability.

Scene in Blender:
instancing1.jpg

Scene in Octane standalone + scattering:
pikmin_fanart_crystal_cave.jpg

Any thoughts?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Supporting LuxCoreRender with Phantom Scatter

Post by Dade »

Phantom107 wrote: Sun Nov 15, 2020 11:09 pm Workflow looks like this:

instancing_support_fixed.jpg
I suggest you to focus only on the second scenario: LuxCoreRender standalone is intended as a sample to show developers how to use LuxCore API. It is not really intended for end users (and it is not used by 99% of them).

It may be useful for testing/development but it doesn't make sense as target for a commercial product.
Phantom107 wrote: Sun Nov 15, 2020 11:09 pm Let's imagine we want to instance around grass pieces for an exterior scene, which is a totally common use-case. I don't see instancing in the SDL page (https://wiki.luxcorerender.org/LuxCore_ ... erogeneous)
As general rule, LuxCore creates an instance automatically when you refer to the same .ply file. For instance, this is the declaration of 3 instances of the same object:

Code: Select all

scene.objects.m1.material = redmatte
scene.objects.m1.ply = scenes/bigmonkey/bigmonkey.ply
scene.objects.m1.transformation = 0.5 0.0 0.0 0.0  0.0 0.5 0.0 0.0  0.0 0.0 0.5 0.0  -8.0 2.0 0.0 1.0
scene.objects.m2.material = redmatte
scene.objects.m2.ply = scenes/bigmonkey/bigmonkey.ply
scene.objects.m2.transformation = 0.5 0.0 0.0 0.0  0.0 0.5 0.0 0.0  0.0 0.0 0.25 0.0  -4.0 2.0 0.0 1.0
scene.objects.m3.material = redmatte
scene.objects.m3.ply = scenes/bigmonkey/bigmonkey.ply
scene.objects.m3.transformation = 0.5 0.0 0.0 0.0  0.0 0.5 0.0 0.0  0.0 0.0 0.5 0.0  0.0 2.0 0.0 1.0
It instantiates the same "scenes/bigmonkey/bigmonkey.ply" geometry 3 times.
Phantom107 wrote: Sun Nov 15, 2020 11:09 pm A number of 100,000 grass pieces is easily reached. Am I understanding it correctly that I should now call a grass object 100,000 times inside the *.SCN file? I am hoping that if it's not yet supported, a feature can be developed where an object can reference a *.CSV file and then use those instance matrices, in the exact same format as is now requested by the scene.objects.<object name>.transformation call
Again, .cfg/.scn files are more a useful tool for testing/developement. For instance, BlendLuxCore creates the scene in memory (i.e. no .cfg/.scn file involved) and in order to export particles system (i.e. many thousands of instances), it creates a single object and than creates many thousands of instances with a single DuplicateObject() LuxCore API call: https://github.com/LuxCoreRender/LuxCor ... re.h#L1011

LuxCore SDL already supports special formats like cyHairFile (http://www.cemyuksel.com/research/hairmodels) for hairs, strands, etc. They are mostly useful to fast export/import large amount of information. Your .csv pretty much fall in the same category.

As far as I can see, your (second) scenario requires:

1) to extend LuxCore SDL to support your .csv file format. Can you post a .csv example file ? I would like to check exactly what kind of information are there.

2) to extend BlendLuxCore to have some kind of support for a proxy object. A virtual object referring the .csv file. BlendLuxCore could even further automate the process by exporting the .obj file and running PhantomScatter executable.
Support LuxCoreRender project with salts and bounties
User avatar
Phantom107
Posts: 9
Joined: Fri Nov 13, 2020 10:01 am

Re: Supporting LuxCoreRender with Phantom Scatter

Post by Phantom107 »

Thanks for the reply,

I agree only scenario 2 is viable, since LuxCoreRender doesn't have a standalone dedicated UI. I did want to explain both to make myself clear.

The DuplicateObject call in the API is great, I'm taking it that after calling this to create 1000 objects, the API is then called 1000 seperate times using UpdateObjectTransformation to set them in place?

A CSV file is nothing but a list of transforms, just like you posted in your example with the 3 objects. So in this case this is the entire *.CSV file, it's a perfect copy from your transform settings (but with the double spaces removed):

Code: Select all

0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.5 0.0 -8.0 2.0 0.0 1.0
0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.25 0.0 -4.0 2.0 0.0 1.0
0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 2.0 0.0 1.0
So what could work is that your code would instead be this:

Code: Select all

scene.objects.m1.material = redmatte
scene.objects.m1.ply = scenes/bigmonkey/bigmonkey.ply
scene.objects.m1.transformation = scenes/bigmonkey/instances.csv
So instead of a transform matrix, it's given the path to the file scenes/bigmonkey/instances.csv that has the instancing matrices.

Maybe it's better to see if the community actually has a need for Phantom Scatter inside Blender? It could be included in some kind of poll or something, among other features that people would like to have. It does looks like supporting the CSV is not that much of a stretch, given the transforms in the CSV are identical and instancing is already supported. Even in Blender it can be useful, since I know how the editor bogs down under the stress of many objects.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Supporting LuxCoreRender with Phantom Scatter

Post by Dade »

Phantom107 wrote: Mon Nov 16, 2020 8:05 pm The DuplicateObject call in the API is great, I'm taking it that after calling this to create 1000 objects, the API is then called 1000 seperate times using UpdateObjectTransformation to set them in place?
Nope, you are passing an array of transformations directly to the DuplicateObject(), UpdateObjectTransformation() is intended for fast object editing.
Phantom107 wrote: Mon Nov 16, 2020 8:05 pm A CSV file is nothing but a list of transforms, just like you posted in your example with the 3 objects. So in this case this is the entire *.CSV file, it's a perfect copy from your transform settings (but with the double spaces removed):

Code: Select all

0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.5 0.0 -8.0 2.0 0.0 1.0
0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.25 0.0 -4.0 2.0 0.0 1.0
0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 2.0 0.0 1.0
But aren't you instantiating multiple different objects and/or using different materials ? Do you handle only a single object for each .csv ?
Phantom107 wrote: Mon Nov 16, 2020 8:05 pm So what could work is that your code would instead be this:

Code: Select all

scene.objects.m1.material = redmatte
scene.objects.m1.ply = scenes/bigmonkey/bigmonkey.ply
scene.objects.m1.transformation = scenes/bigmonkey/instances.csv
This can not work because it is the definition of a single object named "m1" but it can be as easy with just a different syntax. It is only a syntax difference (you have keep in mind that LuxCore SDL/API doesn't only support scene definition but also scene editing so some aspect like object names, etc. are important for further editing).
Phantom107 wrote: Mon Nov 16, 2020 8:05 pm Maybe it's better to see if the community actually has a need for Phantom Scatter inside Blender? It could be included in some kind of poll or something, among other features that people would like to have.
I'm afraid you are going to need more a crystal ball than a poll but if you need one, sure I can put a poll up. It is a commercial evaluation and I have sincerely no idea of what you can get out of it (or what you may consider a success or not).
Support LuxCoreRender project with salts and bounties
User avatar
Phantom107
Posts: 9
Joined: Fri Nov 13, 2020 10:01 am

Re: Supporting LuxCoreRender with Phantom Scatter

Post by Phantom107 »

Instancing in apps like Octane is intended to be used all with the same material. The materials link up to the object, the object is then linked to the instancing node and this is straight to output. Variety is achieved by giving users the 'instance texture' node, that is random 0-1 for every instance. You can use that texture input as you wish.

I think BlendLuxCore can be expanded by feeding the list of transforms straight into DuplicateObject API call then.
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Supporting LuxCoreRender with Phantom Scatter

Post by B.Y.O.B. »

Phantom107 wrote: Mon Nov 16, 2020 8:05 pm Maybe it's better to see if the community actually has a need for Phantom Scatter inside Blender? It could be included in some kind of poll or something, among other features that people would like to have.
I don't think a poll among users about a technical decision makes sense. Without hard data about the performance of your approach vs. existing instancing methods (e.g. through particles or dupliverts in Blender) nobody can make an informed decision.
So it might be best to program a proof-of-concept and check if important points would work out: is it faster at setting up the instances than existing methods, will viewport updates work (e.g. when the instancer is moved or the instanced mesh is edited), etc.

After you can present the findings to users, it might make sense to make a poll asking "would you buy a product with these features, and if yes, at which price".
User avatar
Phantom107
Posts: 9
Joined: Fri Nov 13, 2020 10:01 am

Re: Supporting LuxCoreRender with Phantom Scatter

Post by Phantom107 »

I'll work out a proof of concept ;)
Post Reply