Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    shader and videopost

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 471 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 10/12/2008 at 11:51, xxxxxxxx wrote:

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

      ---------
      hello all,
      i have my channel shader and it return some pixel color value in output.
      my question is: can i print shder resoult in a custom multipass buffer?
      preaps i need to make a videpost plugin, but there are an example or some experience on this issue?
      thanks
      Franz

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 11/12/2008 at 09:35, xxxxxxxx wrote:

        any help ?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 15/12/2008 at 08:19, xxxxxxxx wrote:

          You have to do allocate a multipass buffer (VPBuffer) in a videopost effect. In your shader you access the buffer through Render::GetBuffer(VPBUFFER_POSTEFFECT,your_id). Use GetRenderInstance() to get the Render* pointer. I will try to put an example together.

          cheers,
          Matthias

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 16/12/2008 at 06:03, xxxxxxxx wrote:

            Here a simple example. Basically I allocate buffers in the videopost and store the pointers in the container of the videopost. I read out the container in the shader then and fill the buffer from within ShaderData::Output(). You could also use ExecuteLine() in the videopost to display the buffer on the fly.

            the shader

            > \> #include "c4d.h" \> #include "c4d_symbols.h" \> #include "xmandelbrot.h" \> \> \> class MandelbrotData : public ShaderData \> { \>      public: \>           virtual Bool Init          (GeListNode \*node); \>           virtual     Vector Output(PluginShader \*chn, ChannelData \*cd); \> \>           virtual     LONG InitRender(PluginShader \*sh, InitRenderStruct \*irs); \>           virtual     void FreeRender(PluginShader \*sh); \> \>           static NodeData \*Alloc(void) { return gNew MandelbrotData; } \>       \>      private: \>           Vector \*m_varrBuf; \>           LONG m_lWidth; \> }; \> \> Bool MandelbrotData::Init(GeListNode \*node) \> { \>      BaseContainer \*data = ((PluginShader\* )node)->GetDataInstance(); \> \>      m_varrBuf = NULL; \>      m_lWidth = 0; \> \>      return TRUE; \> } \> \> LONG MandelbrotData::InitRender(PluginShader \*sh, InitRenderStruct \*irs) \> { \>      BaseContainer \*data = sh->GetDataInstance(); \> \>      if(irs->vd) \>      { \>           PluginVideoPost \*pvp = NULL; \>           pvp = irs->vd->FindVideoPost(1000968); \> \>           if(pvp) \>           { \>                BaseContainer \*pdata = pvp->GetDataInstance(); \> \>                BaseContainer \*subbc = pdata->GetContainerInstance(1023441); \> \>                VPBuffer \*buf = NULL; \>                buf = (VPBuffer\* )subbc->GetVoid(1000); \> \>                m_varrBuf = (Vector\* )subbc->GetVoid(1001); \> \>                if(buf && m_varrBuf) m_lWidth = buf->GetInfo(VPGETINFO_XRESOLUTION); \>           } \>      } \> \>      return LOAD_OK; \> } \> \> void MandelbrotData::FreeRender(PluginShader \*sh) \> { \> } \> \> Vector MandelbrotData::Output(PluginShader \*chn, ChannelData \*cd) \> { \>      if(cd->vd) \>      { \>           LONG x,y,scale; \> \>           cd->vd->GetXY(&x;,&y;,&scale;); \> \>           if(m_varrBuf) m_varrBuf[((y/scale)\*m_lWidth)+(x/scale)] = Vector(1.0, 0.0, 0.0); \>      } \> \>      return 0.0; \> } \> \> // be sure to use a unique ID obtained from www.plugincafe.com \> #define ID_MANDELBROT     1001162 \> \> Bool RegisterMandelbrot(void) \> { \>      // decide by name if the plugin shall be registered - just for user convenience \>      String name=GeLoadString(IDS_MANDELBROT); if (!name.Content()) return TRUE; \>      return RegisterShaderPlugin(ID_MANDELBROT,name,0,MandelbrotData::Alloc,"Xmandelbrot",0); \> } \>

            the videopost

            > \> #include "c4d.h" \> #include "c4d_symbols.h" \> #include "vpcolorize.h" \> \> \> class ColorizeData : public VideoPostData \> { \>      INSTANCEOF(ColorizeData,VideoPostData) \> \>      public: \>           virtual Bool Init(GeListNode \*node); \>           virtual void Free(GeListNode \*node); \>           virtual void AllocateBuffers(PluginVideoPost \*node, Render \*render, BaseDocument \*doc); \>           virtual LONG Execute(PluginVideoPost \*node, VideoPostStruct \*vps); \>           virtual LONG GetRenderInfo(PluginVideoPost \*node) { return VIDEOPOST_REFRESH/\*|VIDEOPOST_EXECUTELINE\*/; } \> \>           static NodeData \*Alloc(void) { return gNew ColorizeData; } \> \>      private: \>           LONG m_lFxId; \>           Vector \*m_varrBuf; \> }; \> \> Bool ColorizeData::Init(GeListNode \*node) \> { \>      PluginVideoPost \*pp = (PluginVideoPost\* )node; \>      BaseContainer \*dat = pp->GetDataInstance(); \> \>      m_varrBuf = NULL; \> \>      return TRUE; \> } \> \> void ColorizeData::AllocateBuffers(PluginVideoPost \*node, Render \*render, BaseDocument \*doc) \> { \>      BaseContainer \*data = node->GetDataInstance(); \> \>      LONG needbitdepth = 32; // also 16 and 32 are possible \> \>      m_lFxId = render->AllocateBufferFX(VPBUFFER_POSTEFFECT, "Colorize", needbitdepth, TRUE); \> } \> \> LONG ColorizeData::Execute(PluginVideoPost \*node, VideoPostStruct \*vps) \> { \>      BaseContainer \*data = node->GetDataInstance(); \> \>      if (vps->vp==VP_RENDER && vps->open) \>      { \>           VPBuffer \*buf = NULL; \>           buf = vps->render->GetBuffer(VPBUFFER_POSTEFFECT, m_lFxId); \>           if(!buf) return RAY_NOMEM; \>            \>           BaseContainer subbc; \>           subbc.SetVoid(1000,buf); \> \>           const LONG w = buf->GetInfo(VPGETINFO_XRESOLUTION); \>           const LONG h = buf->GetInfo(VPGETINFO_YRESOLUTION); \> \>           m_varrBuf = bNew Vector[w\*h]; \>           if(!m_varrBuf) return RAY_NOMEM; \> \>           subbc.SetVoid(1001,m_varrBuf); \> \>           data->SetContainer(1023441, subbc); \>      } \> \>      else if (vps->vp==VP_RENDER && !vps->open) \>      { \>           VPBuffer \*buf = NULL; \>           buf = vps->render->GetBuffer(VPBUFFER_POSTEFFECT, m_lFxId); \>           if(!buf) return RAY_NOMEM; \> \>           if(buf && m_varrBuf) \>           { \>                const LONG w = buf->GetInfo(VPGETINFO_XRESOLUTION); \>                const LONG h = buf->GetInfo(VPGETINFO_YRESOLUTION); \> \>                LONG x,y; \>                const LONG cpp = buf->GetInfo(VPGETINFO_CPP); \> \>                SReal \*b,\*buffer = (SReal\* )GeAlloc(cpp\*w\*sizeof(SReal)); \>                if (!buffer) return RAY_NOMEM; \> \>                for(y=0; y<h; y++) \>                { \>                     buf->GetLine(0,y,w,buffer,32,TRUE); \> \>                     for (b=buffer,x=0;x<w;x++,b+=cpp) \>                     { \>                          Vector col = m_varrBuf[(y\*w)+x]; \>                          b[0] = col.x; \>                          b[1] = col.y; \>                          b[2] = col.z; \>                     } \>                     buf->SetLine(0,y,w,buffer,32,TRUE); \>                } \>                GeFree(buffer); \>           } \>      } \>            \>      return RAY_OK;      \> } \> \> void ColorizeData::Free(GeListNode \*node) \> { \>      if(m_varrBuf) bDelete(m_varrBuf); \> } \> \> \> // be sure to use a unique ID obtained from www.plugincafe.com \> #define ID_COLORIZEVIDEOPOST 1000968 \> \> Bool RegisterVPTest(void) \> { \>      // decide by name if the plugin shall be registered - just for user convenience \>      String name=GeLoadString(IDS_VIDEOPOST); if (!name.Content()) return TRUE; \>      return RegisterVideoPostPlugin(ID_COLORIZEVIDEOPOST,name,0,ColorizeData::Alloc,"VPcolorize",0,0); \> } \>

            cheers,
            Matthias

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 16/12/2008 at 14:27, xxxxxxxx wrote:

              hello Matthias,
              thank you very mutch, i'll study this
              Franz

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 01/03/2010 at 08:47, xxxxxxxx wrote:

                Hi Matthias,

                how would one go about using this technique for a volumetric shader and inside CalcTransparency()? It works fine with CalcVolumetric but CalcTransparency seems to have problems with this. Well, at least as soon as there are reflections involved. As there are no ray bits set it doesn´t make it easier. Any idea why Reflections affect Calctransparency (shadow calculations)?

                thx

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post