Particles and RenderDocument
-
I have a scene with the new 2024.4 particles, like a default Basic Emitter for instance.
I clone the scene and then call
RenderDocument()
with theNODOCUMENTCLONE
flag on a thread, however that does not render the particles.BaseDocument* renderDocument = static_cast<BaseDocument*>(myDocument->GetClone(COPYFLAGS_DOCUMENT, nullptr)); ... RenderDocument(renderDocument, renderSettings, nullptr, nullptr, bitmap, RENDERFLAGS_EXTERNAL | RENDERFLAGS_BATCHRENDER | RENDERFLAGS_NODOCUMENTCLONE, this->Get());
If
RenderDocument()
is called without theNODOCUMENTCLONE
flag, then the particles are rendered fine.I assume when RenderDocument clones the scene, it also triggers the particles to be simulated. Can you help me with what's missing to achieve the same behavior?
Have to note, no issue, if the particles are cached.
-
Hey @peter_horvath,
Thank you for reaching out to us. I had a quick look at
RenderDocument
and in the case ofRENDERFLAGS_NODOCUMENTCLONE
not being passed, it does not really do anything obvious which would explain this at first glance (e.g., aBaseDocument::ExecutePasses
call). The main thing that differs is that we use anAliasTrans
when cloning, which might cause the issue. We are of course also doing a lot of other things but I currently do not see how they could impact particles.AliasTrans t; if (!t.Init(maindoc)) goto error; copy = (BaseDocument*)maindoc->GetClone(flags, &t);
The problem with the code snippet is that we use the internal version of that type and later on a method which is not exposed on the public type. But maybe just emulating using an alias alone will help.
Is there anything special about the context where you call this
RenderDocument
? I assumeRENDERFLAGS_NODOCUMENTCLONE
and the other flags are your own symbols. Have you checked if they indeed resolve toRENDERFLAGS::NODOCUMENTCLONE
? But last but not least this smells a little bit like a bug to me - that the simulation scene is not correctly initialized when you clone a document or something like that. Will poke one of the particle developers tomorrow if they know anything about this.Cheers,
Ferdinand -
Hey Ferdinand,
Nothing special about the context. Tried cloning with AliasTrans, but it does not help.
I'm attaching a simple code taken from the manual in case you want to reproduce the issue. The code adds two commands, one calling RenderDocument() with the
RENDERFLAGS::NODOCUMENTCLONE
flag and one without. You can see, that the one with the flag does not render the particles. Note, that no manual cloning is involved in the example, just loading the document, which might indicate that it's indeed a bug.Thanks,
Peter -
Hey @peter_horvath,
first of all once again thanks for your always on point demo projects. That makes it for us that much easier to answer things when we do not have to guess half the things the external developers are doing.
I talked with the particles team and they say this might be related to a bug they are already aware of - rendering particles in the Picture Viewer does not work properly at the moment. I also gave it a quick spin with your demo project and can confirm that this does not work (for me it even does not work in both cases).
The reason why this fails is apparently that the proper preroll is missing although this does not explain everything I encountered. You could combat that with setting the cloned document to frame 0 and then executing the passes up to the point where you want to render. But I did not try that because for me it does not work when you clone or not (and also not in the PV which uses the 'proper' render pipeline), so that seemed a bit pointless. And as said before, I looked at
RenderDocument
and I saw there no preroll code (but might have overlooked it).The file
particle_test_render.c4d
was missing in your project, which is why I had to create my own. Which render engine did you use to render the particles in your tests? Arnold? Because I did use Redshift which might explain differences.I would recommend opening a bug ticket for this. I have already moved this issue to our bug forum. You can either open the ticket in our bug tracker yourself as an MRD (then you will be able to see the ticket) or I can do it for you (then you won't). If you decide to do it yourself, please add the test file I attached below (or create your own if you have something more fitting). Please also give me a heads-up with the ticket ID so that I can attach the responsible developers to that issue.
Finally, in the ticket or here, a classification of how critical this is for you would be great.
Cheers,
Ferdinand -
-
Hey Ferdinand,
Thanks for the reply. Sorry, I forgot to include the test scene. It was just a simple Basic Emitter and I rendered it with Redshift.
You could combat that with setting the cloned document to frame 0 and then executing the passes up to the point where you want to render.
Yeah, I've tried that actually, but did not solve the problem.
I logged the issue as ITEM#506966 (including the tests scene in the zip this time).
It is not critical for us at the moment, since this is a specific use-case and not using the NODOCUMENTCLONE flag can be a good workaround.
Thank you,
Peter -
Hey @peter_horvath,
thank you for the bug report and no need to apologize for the small mistake, as I said, your code examples are usually very helpful - no fluff to the point
Cheers,
Ferdinand