Force shader OGL update

On 07/05/2018 at 15:31, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R19 
Platform:   Windows  ;   Mac OSX  ; 
Language(s) :     C++  ;

Is there a way to force the shaders to update so that they get a call to InitGLImage? Or a way to send a message to shaders so that I can have them set their own dirty flags, which I would hope in turn would trigger a call to InitGLImages.

The only way I can see to get shaders to update is by advancing one frame in the timeline, which is a very hacky solution.

On 08/05/2018 at 05:15, xxxxxxxx wrote:

Hi Kent, thanks for writing us.

With reference to your request, you can easily force InitGLImage being called by marking a shader as dirty using BaseShader::SetDirty(DIRTYFLAGS_DATA). This will automatically force the shader preview thread to get re-executed and, consequently the InitGLImage() to be called.

Hope this helps, Riccardo.

On 08/05/2018 at 18:18, xxxxxxxx wrote:

Hi Riccardo,

Thanks for that.

Do you know of a way to send a message to a shader? IE something like CoreMessage. Then I can pick up the message in the shader itself and set its dirty flag.

Otherwise I will either have to scan the document looking for the shader on all materials, or shaders will need to register themselves with a scenehook or object   so that I can call them when required to make them dirty.

Being able to send a message would be the ideal way.


On 10/05/2018 at 16:31, xxxxxxxx wrote:

I have gone with the idea of registering and deregistering shaders with an object. The object can then directly tell shaders that they are dirty and need updating in the viewport. Note that this a very specific solution that fits my needs and is not a general solution to the problem.