Keeping Hair AA in own volu shader?



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

    On 13/11/2007 at 07:54, xxxxxxxx wrote:

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

    ---------
    Hi,

    I have a volumetric environement shader and I would like to support c4ds hair renderering (raster) because a lot of my customers are now using hair.

    My shader is dependant on the current ray hit information and changes vd->col and vd->trans. It has no problems with AA of normal polygonal objects. It´s retained.

    However, when I use the Hair fragments data to detect hair in the scene and take its transparency information to blend with my shaders color and transparency, the hair AA is destroyed.

    While debugging a pixel the fragment information gives me a transparency of 0.86 for example. However, when I do render the pixel, it looks like the transparency is like full opacity (probably due to AA I assume).

    This is how I get the transparency from the fragments:

    > _vd- >GetXY(x,y,scale);
    >     //Assuming x and y should be in screen resolution not render resolution
    >     HairFragment *hf     =     hpost->GetFragments(Real(x)/Real(scale),Real(y)/Real(scale),cnt,vd->GetCurrentCPU());
    >
    >         if (bit8)
    >         {
    >               for (i=0;i<cnt;i++)
    >               {
    >                    hairtrans=hairtrans*hf->trans;
    >               }
    >         }
    > _

    What is the correct way to maintain the Hair AA and correctly blend with my volumetric data? Or rather how do I correctly get the "real" transparency of the hair at that pixel from within CalcVolumetric in an environment shader?

    Thank you



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

    On 13/11/2007 at 10:54, xxxxxxxx wrote:

    You might want to try calling the hair post effect CalcVolumetric direct and let hair itself deal with returning to you the correct data. For example, the following code should let you easily get hair for the render and even fake any occlusions:

    > _
    > LONG ReconstructData::Execute(PluginVideoPost *node, VideoPostStruct *vps)
    > {
    >      if (vps->vp==VP_INNER && vps->open)
    >      {
    >           vps->vd->SkipRenderProcess();
    >      }
    >
    >      if (!vps->vd || vps->vp!=VP_INNER || vps->open || *vps->error!=RAY_OK || vps->thread->TestBreak()) return RAY_OK;
    >
    >      VPBuffer *rgba    = C4DOS.Sh->VPGetBuffer(vps->render,VPBUFFER_RGBA,NOTOK);
    >      RayParameter *ray = vps->vd->GetRayParameter(); // only in VP_INNER & VP_RENDER
    >      if (!ray) return RAY_NOMEM;
    >      if (!rgba) return RAY_NOMEM;
    >
    >      LONG x1,y1,x2,y2,x,y,cnt;
    >
    >      // example functions
    >      LONG cpp = rgba->GetInfo(VPGETINFO_CPP);
    >
    >      x1 = ray->left;
    >      y1 = ray->top;
    >      x2 = ray->right;
    >      y2 = ray->bottom;
    >      cnt = x2-x1+1;
    >
    >      PluginVideoPost *hvp=vps->vd->FindVideoPost(VPhair);
    >      VideoPostData *vpd=(hvp)?(VideoPostData* )hvp->GetNodeData() :NULL;
    >
    >      SReal *b,*buffer = (SReal* )GeAlloc(cpp*cnt*sizeof(SReal));
    >      if (!buffer) return RAY_NOMEM;
    >
    >      for (y=y1;y<=y2;y++)
    >      {
    >           if (vps->vd->TestBreak()) break;
    >
    >           rgba->GetLine(x1,y,cnt,buffer,32,TRUE);
    >
    >           for (b=buffer,x=x1;x<=x2;x++,b+=cpp)
    >           {
    >                if (vps->vd->TestBreak()) break;
    >
    >                if (vpd)
    >                {
    >                     Ray ray;
    >
    >                     vps->vd->GetRay(x,y,&ray;);
    >                     vps->vd->SetXY(x,y);
    >                     vps->vd->raybits=0;
    >                     vps->vd->lhit=0;     // set to !=0 to fake a geom hit
    >                     vps->vd->op=NULL;     // set to !=NULL to fake a geom hit
    >                     vps->vd->p=Vector();
    >                     vps->vd->dist=0;     // set to the distance to any geom if lhit/op set.
    >                     vps->vd->ray=&ray;     // if you set this at before close it needs to be restored
    >
    >                     vpd->CalcVolumetric(hvp,vps->vd);
    >
    >                     b[0]=vps->vd->col.x;
    >                     b[1]=vps->vd->col.y;
    >                     b[2]=vps->vd->col.z;
    >                }
    >           }
    >
    >           rgba->SetLine(x1,y,cnt,buffer,32,TRUE);
    >      }
    >
    >      GeFree(buffer);
    >
    >      return RAY_OK;     
    > }
    > _



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

    On 14/11/2007 at 00:19, xxxxxxxx wrote:

    Great! Thank you David. I will try that today! Looks like the right way to go. :)



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

    On 14/11/2007 at 04:38, xxxxxxxx wrote:

    Seems to work fine. :)


Log in to reply