Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

InitRender from Execute()

 Post Reply Post Reply
Author
Message
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 89
Post Options Post Options   Quote rsodre Quote  Post ReplyReply Direct Link To This Post Topic: InitRender from Execute()
    Posted: 2018 Aug 08 at 11:07am

User Information:

Cinema 4D Version:   R19 
Platform:   Windows  ; Mac  ;  Mac OSX  ; 
Language(s):       

---------

Hello,

I have a scene that has a SHADERLINK parameter, initialized with a texture. It works, I can sample, no problem.
But every time I load that scene, I'm getting a INITRENDERRESULT_USERBREAK error when I call InitRender(), from my TagData::Execute().
If I immediately change some parameter to trigger Execute() again, InitRender will succeed and sample as expected.

From the docs I see the error has something to do with threading (Thread has been canceled).
Should I init irs.vd? How? I can't find a way to get a Render* anywhere in the docs to access GetInitialVolumeData()

Here's what I do, in my Execute():

GeData data;
node->GetParameter( parameterId, data, DESCFLAGS_GET_0 );
auto shader = static_cast<BaseShader*>( data.GetBaseLink() ); 
InitRenderStruct irs( doc );
irs.thread = bt;
auto error = shader->InitRender( irs );
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1847
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Aug 09 at 6:33am
Hi,

we probably need more details here. You seem to have a TagData plugin, which links to a shader. Who owns this shader or where is the shader inserted into?
It seems at least unusual to me to call InitRender() from within the execution pipeline. Why do you need to render the shader manually at all?
Please forgive my questions, I might be missing something. Therefore a more detailed explanation of what you are actually trying to do and what's the rough architecture of your plugin could help a lot.

Cheers,
Andreas
SDK Support Engineer
Back to Top
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 89
Post Options Post Options   Quote rsodre Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Aug 10 at 5:39pm
My shaders are declared in the resource file of a tag, do I still need to insert them in the object to use? If I list the object's shader, there's nothing there.
But so far I just do GetParameter, InitRender and Sample.

It seems at least unusual to me to call InitRender() from within the execution pipeline. Why do you need to render the shader manually at all?

I don't understand the question. The docs make clear that we need to InitRender before Sample. I read and process all the attributes in Execute, is that odd?

Re-reading the BaseShader manual brings me some more questions...

We need to insert the shader in an object to use it, so after we're done do we need to remove it? Using what, GeListNode::Remove() ?

If the shader parameters are updated in the Attribute Manager, should we InitRender again?

That cycle is not clear to me, seems that every time that I need to sample the sader, do I need to do all that? GetParameter, InsertShader, InitRender, Sample, FreeRender, Remove.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1847
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: Today at 8:04am
Hi,

first of all I have to apologize, my question was stupid. I checked our code base and it's fine to sample a shader inside of the execution pipeline. Sorry.

Regarding insertion of the shader. It depends on how the shader gets created, that's linked in your SHADERLINK parameter. If you create the shader manually and add the link, then you need to insert it properly, in this case into the tag. You also don't need to insert and remove it all the time, but you'd insert it once and remove upon destruction. If on the other hand the shader gets created by the user with the shader popup next to the link field, then the shader is already properly inserted and you don't need to care.

Cheers,
Andreas
SDK Support Engineer
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.125 seconds.