shader plugin / problem with bump channel

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

On 04/06/2009 at 03:16, xxxxxxxx wrote:

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

---------
Hi there,

i have a working ChannelShader Plugin which does some colorfull calculations. But it does not work in the Bump Channel. Is there something special to consider?

cheers,
Ello

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

On 08/06/2009 at 06:40, xxxxxxxx wrote:

Please read the New bump algorithm paragraph in the Changes to the material system in 8.5 chapter in the SDK docu.

cheers,
Matthias

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

On 08/06/2009 at 14:10, xxxxxxxx wrote:

thanks, i'll do so
cheers,
ello

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

On 25/06/2009 at 14:15, xxxxxxxx wrote:

hm, after reading the docu i still have no clue how to pass my results in the bump channel..

when i try to use _
if (GET_TEX_CHANNEL(cd- >texflag) == CHANNEL_BUMP)
{
return chn->SampleBump(cd,SAMPLEBUMP_MIPFALLOFF);
}
_
cinema just closes as soon as i apply my shader to the bump channel

thanks for any help,
ello

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

On 28/06/2009 at 08:26, xxxxxxxx wrote:

I put together a simple turbulence shader which shows how to use the 4 sampling points for a UV based shader.

First it is important to return CHANNEL_BUMP_SUPPORT in GetRenderInfo(). Then you check if you are in the bump channel and check which is the current of the four bump samples with GET_TEX_BUMP_SAMPLE(cd->texflag). Depending on the bump sample you have to shift your UV coordinates for your shader calculation.

> \> #include "c4d.h" \> #include "c4d_symbols.h" \> #include "xmandelbrot.h" \> \> \> class MandelbrotData : public ShaderData \> { \>      public: \>           virtual Bool     Init(GeListNode \*node); \>           virtual LONG     GetRenderInfo(PluginShader\* sh) { return CHANNEL_BUMP_SUPPORT; } \>           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: \>           Real m_rDelta; \>           Real m_rScale; \> }; \> \> Bool MandelbrotData::Init(GeListNode \*node) \> { \>      BaseContainer \*data = ((PluginShader\* )node)->GetDataInstance(); \> \>      data->SetReal(MANDELBROTSHADER_DELTA, 1.0f); \>      data->SetReal(MANDELBROTSHADER_SCALE, 1.0f); \> \>      m_rDelta = 0.0f; \>      m_rScale = 0.0f; \> \>      return TRUE; \> } \> \> LONG MandelbrotData::InitRender(PluginShader \*sh, InitRenderStruct \*irs) \> { \>      BaseContainer \*data = sh->GetDataInstance(); \> \>      m_rDelta = data->GetReal(MANDELBROTSHADER_DELTA, 0.0f) / 100.0f; \>      m_rScale = 1.0f / data->GetReal(MANDELBROTSHADER_SCALE, 0.001f); \> \>      return LOAD_OK; \> } \> \> void MandelbrotData::FreeRender(PluginShader \*sh) \> { \> } \> \> Vector MandelbrotData::Output(PluginShader \*chn, ChannelData \*cd) \> { \>      // Scale the UVs = scaling the turbulence \>      Vector uv = cd->p\*m_rScale; \> \>      // Is this a bump calculation? \>      if (GET_TEX_CHANNEL(cd->texflag) == CHANNEL_BUMP) \>      { \>           // Which of the four samples are we talking about? \>           switch (GET_TEX_BUMP_SAMPLE(cd->texflag)) \>           { \>                // Shift the UV surface point. \>                case 0: uv.x -= m_rDelta; break; \>                case 1: uv.x += m_rDelta; break; \>                case 2: uv.y -= m_rDelta; break; \>                case 3: uv.y += m_rDelta; break; \>           } \>      } \> \>      uv.z = 0.0f; \> \>      return Turbulence(uv, 4.0f, TRUE); \> } \> \> \> // 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); \> } \>

Hope this helps.

cheers,
Matthias

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

On 28/06/2009 at 11:55, xxxxxxxx wrote:

thank you very much matthias, now i understand. and i found my main fault
cheers,
elli