Shader "invalidation"



  • On 21/03/2013 at 08:16, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   14 
    Platform:      
    Language(s) :     C++  ;

    ---------
    How does one "invalidate" all materials that utilise a particular shader?

    My shader depends on external dependencies, and if any one of these external dependencies are changed I want to make sure any objects that make use of my ShaderData derived shader to be refreshed.

    The shader is a channel shader, so can be set in place of a regular texture in a channel slot for a material. I thought (because of this) I would be able to walk the documents material list and use the materials GetFirstShader / GetNext , but this does not seem to work. The only shaders I get back are named "Bitmap". I'm guessing that I have to delve deeper into the returned shader to work out if any of its channels are utilising mine in some way, but I'm not sure how best to do this.

    The plan was to search for materials that utilise my shader and just call Update on those materials to get everything re-evaluated properly.

    Ideally though I'd like to ask C4D to refresh all things that utilise my shader direct, but that does not seem to be possible (and hence the idea of traversing materials above).

    Any pointers more than welcome!

    -Simon



  • On 05/04/2013 at 08:04, xxxxxxxx wrote:

    Hi Simon,

    I think you could use shader->MultiMessage(MULTIMSG_ROUTE_UP, MSG_UPDATE, NULL) to tell the objects using your shader to update.
    Sorry for the late reply.


Log in to reply