On 16/06/2015 at 10:16, xxxxxxxx wrote:
Cinema 4D Version: 15+
Platform: Windows ;
Language(s) : C++ ;
I got my own renderer, it works fine in viewport and picture viewer, but it doesn't get called in material preview.
MatPreviewGenerateImage* image = (MatPreviewGenerateImage* )data;
Int32 w = image->pDest->GetBw();
Int32 h = image->pDest->GetBh();
BaseContainer bcRender = image->pDoc->GetActiveRenderData()->GetData();
bcRender.SetInt32(RDATA_RENDERENGINE, ID_MYRENDERER);//my video post renderer ID
image->pDest->Clear(0, 0, 0);
image->lResult = RenderDocument(image->pDoc, bcRender, nullptr, nullptr, image->pDest,
RENDERFLAGS_EXTERNAL | RENDERFLAGS_PREVIEWRENDER, image->pThread);
return MaterialData::Message(node, type, data);
am I missing something?
On 16/06/2015 at 10:24, xxxxxxxx wrote:
to be precise, RenderDocument() is called, but it doesn't call my renderer Execute().
On 17/06/2015 at 06:38, xxxxxxxx wrote:
changing the RDATA_RENDERENGINE value is just that – you change the value of the parameter and nothing else. The preview can only render using your render engine if you actually add your render engine to the scene. This means that you have to add the BaseVideoPost of your render engine to the document's render data using InsertVideoPost(). Something like this:
RenderData* rdata = image->pDoc->GetActiveRenderData();
BaseVideoPost* myRenderer = BaseVideoPost::Alloc(MY_RENDERER_ID);
On 17/06/2015 at 06:52, xxxxxxxx wrote:
thanks a lot Sebastian, should I do this everytime I call RenderDocument()? or do it once in the material init() function?
On 17/06/2015 at 11:59, xxxxxxxx wrote:
well, how often do you call RenderDocuent()? This has nothing to do with MaterialData::Init(). The document that is used by the material preview is no copy of your current document so its render settings are not your render settings. This is why you have to add the video post.
On 17/06/2015 at 12:03, xxxxxxxx wrote:
well, I call it on material update, so it will be a lot, I just pasted the 3 lines that you posted before RenderDocument() call and it worked, but I was aware if this is the correct thing to do.