Texture file sequence, get exact filename per frame



  • Hi!
    For a render engine plugin, I would like to support animations (file sequences) as textures. In the bitmap shader, there are settings for animation, and c4d the automatically parses the texture file name to identify the frame number part which is modified per frame to render the appropriate texture.

    Is there anyway to get, for a given Bitmap shader and timepoint (BaseTime or frame), the exact texture name that c4d would load for rendering?

    We could try to reverse engineer this of course, but it would be really convenient and more robust if there was a function for accessing this.

    Thanks!
    /Filip



  • Hi,

    I am not sure if that helps, but BaseShader::GetBitmap returns the correct bitmap. I do not have any image sequences lying around here, but I would assume it also does work there. The interpolation offset is determined by the document time of the BaseDocument you are passing to BaseShader::InitRender. As a Python example (I left out all the ifs and whens), the first material needs to be a standard material with some kind of movie in the color channel. Scrubbing the timeline and executing the script will cause it to open the corresponding frame of that movie in the Picture Viewer.

    You could then try to get the filename from that BaseBitmap. BASEBITMAP_DATA might be helpful in that context.

    Cheers,
    zipit

    import c4d
    
    
    def main():
        """
        """
        material = doc.GetFirstMaterial()
        shader = material[c4d.MATERIAL_COLOR_SHADER]
        
        irs = c4d.modules.render.InitRenderStruct(doc)
        shader.InitRender(irs)
        bitmap = shader.GetBitmap()
        shader.FreeRender()
        c4d.bitmaps.ShowBitmap(bitmap)
    
    if __name__=='__main__':
        main()
    


  • Thanks for the input zipit!

    That is promising, but unfortunately does not quite help in my case as I really need the filename rather than the bitmap itself. The rendering in my plugin is also, for various good reasons, not guaranteed to happen within a InitRender()/FreeRender() context.

    /Filip



  • Hi,

    jeah, I already suspected something like that; that is why included the link to BASEBITMAP_DATA. With BaseBitmap::GetData you can access these attribute, including several frame related attributes. The whole thing is flagged as private in both the C++ and Python docs, which usually means that things won't be as easy as one might think, which is why I did not really bother to go down that rabbit hole.

    Not quite sure about the InitRender part. If you want to interpret a Xbitmap BaseShader like Cinema would, you will have to sample it, i,e. init that shader for rendering. Everything else would be an eating the cake without eating it scenraio.

    Cheers,
    zipit



  • That BASEBITMAP_DATA stuff is related to rendering information when a bitmap is displayed in the Picture Viewer (BaseBitmap Manual).



  • @PluginStudent said in Texture file sequence, get exact filename per frame:

    That BASEBITMAP_DATA stuff is related to rendering information when a bitmap is displayed in the Picture Viewer (BaseBitmap Manual).

    Oh, I did not know that. Thanks for the link.



  • Hi @Filip , thanks for reaching out us.

    With regard to your question, I confirm there's no available method in our API that provides you with the exact name of the bitmap used at a certain frame.
    The information about which exact bitmap to fetch from the sequence of textures set in the BitmapShader, is instead calculated programmatically given the data stored in

        BITMAPSHADER_TIMING_FROM
        BITMAPSHADER_TIMING_TO
        BITMAPSHADER_TIMING_FPS
        BITMAPSHADER_TIMING_TIMING
        BITMAPSHADER_TIMING_MODE
        BITMAPSHADER_TIMING_LOOPS
        BITMAPSHADER_TIMING_RANGEFROM
        BITMAPSHADER_TIMING_RANGETO
    

    Best, R



  • @r_gigante Thanks for confirming. We will try to reverse engineer the filenames based on that data.

    Cheers
    /Filip


Log in to reply