4 Replies Latest reply on Jun 29, 2011 5:05 PM by AIF Bob

    Can anyone say why this basic PB crashes AE?

    kaczorefx Level 1

      Hi,

      I wrote a basic light wrap filter - it works in PB but crashes AE immidiately when I apply the filter to a layer.

       

       

      <languageVersion : 1.0;>

       

      kernel efx_lightwrap

       

      <   namespace : "efx LightWrap";

          vendor : "EFX Filip Kaczorek";

          version : 1;

          description : "LightWrap";

          displayname : "EFX LightWrap";

          category : "EFX";

      >

      {

          dependent float maxd;

          dependent float fgam;

       

          input image4 src;

          output pixel4 dst;

       

         parameter float thr

              <

                  minValue: 0.0;

                  maxValue: 0.99;

                  defaultValue: 0.99;

                  aeDisplayName: "alpha threshold";

              >;

       

         parameter int rad

              <

                  minValue: 0;

                  maxValue: 20;

                  defaultValue: 1;

                  aeDisplayName: "radius";

              >;

         parameter float gam

              <

                  minValue: 0.0;

                  maxValue: 1.0;

                  defaultValue: 1.0;

                  aeDisplayName: "falloff shape";

              >;

       

       

       

         parameter float ammount

              <

                  minValue: 0.0;

                  maxValue: 1.0;

                  defaultValue: 1.0;

                  aeDisplayName: "ammount";

              >;

       

         parameter pixel3 lightcol

          <

              minValue: pixel3(0.0,0.0,0.0);

              maxValue: pixel3(1.0,1.0,1.0);

              defaultValue: pixel3(0.0,0.0,1.0);

              description: "Light color.";

              parameterType: "colorRGB";

              aeDisplayName: "Light color";

              aeUIControl: "aeColor";

          >;

       

        void evaluateDependents()

          {

             maxd=distance( float2(0.0,0.0),float2(float(rad),float(rad)) );

              fgam=8.0*gam-7.0;

          }

       

         pixel4 check(pixel4 this_p){

              float dist=9999.0;

              this_p.a=0.0;

              pixel4 p=pixel4(0.0);

              float td=0.0;

              int i=0;

              int j=0;

       

       

              for(i = -rad; i <= rad; i++)

                      {

                        for(j = -rad; j <= rad; j++)

                          {

                            p=sampleNearest(src,outCoord() + float2(float(i),float(j)));

                            if(p.a<thr){

                                   td=distance( float2(0.0,0.0),float2(float(i),float(j)) );

                                   if(dist>td){dist=td;}

                            }

                          } 

                      }

       

              if(dist<9999.0){

                  this_p.a=1.0-(dist/maxd);

                  this_p.a=pow(this_p.a,(1.0-fgam));

                  this_p.rgb=lightcol;

              }

              return this_p;

          }

       

          void

          evaluatePixel()

          {

              pixel4 s_pix=sampleNearest(src,outCoord());

              pixel4 t_pix=s_pix;

              pixel4 lw_pix=s_pix;

       

              if(s_pix.a>thr){

                     lw_pix=check(lw_pix);  

                  }

       

              if(lw_pix.a>0.0){

                   t_pix.rgb=s_pix.rgb+(lw_pix.rgb*pixel3(lw_pix.a*ammount));

              }

       

              dst = t_pix;

          }

       

      }

       

       

      After some experimenting I think it has something to do with sampling the input image inside the check() function.

      If I replace the sampled values with constant ones - it doesn't crash.

      If I move all the calculations up to the main evaluatePixel() function - it doesn't crash.

       

      I'd call it a day with that conclusion if it wasn't for the fact that this is basically my template PB and I have many PB filters built exactly the same way that don't crash.

      Including a Gaussian Filter that does way more sampling within its sub-function.

      So any ideas?

        • 1. Re: Can anyone say why this basic PB crashes AE?
          AIF Bob Level 3

          I'm not seeing anything obviously wrong with your code. When you run it in the toolkit can you try running it in CPU and GPU mode and see if it crashes in both?

           

          Also, what are your system specs? (Mac / Windws, OS, GPU etc.) That will help us to test this on as similar a machine as possible.

           

          Finally, make sure your graphics drivers are up to date.

           

          Bob

          • 2. Re: Can anyone say why this basic PB crashes AE?
            unique_screenname_here

            As Bob noted, I also do not believe the problem is with your filter per se, but is rather a bug in our CPU backend that I believe we've already reported and possibly fixed. I also believe that you should be able to reproduce this bug in the Pixel Bender Toolkit when running your filter on a four channel image in CPU mode. In any case, thanks for reporting this crash.

            • 3. Re: Can anyone say why this basic PB crashes AE?
              kaczorefx Level 1

              In Pixel Bender it runs in both modes.

              It crashes on 3 different machines, although all HP

              Two different workstations and a laptop (so xeons and i7, FireGLv5600, Quadro 4800, GF230 mobile).

              All Win7 x64 and AE CS5.

               

              Like I said, it crashes AE even if I strip the code to only one line in the function: p=sampleNearest...

               

              This seems to be the only thing that gives problems.

               

              Weird thing, THIS IS almost my template filter - I start all my filters looking like that and that one is THE ONLY ONE crashing???

               

              The solution i found was to move the code into the main body - not use a subfunction. Now it works great, though the esthetics of the code suffer

              • 4. Re: Can anyone say why this basic PB crashes AE?
                AIF Bob Level 3

                I've filed this as a bug and we'll look into it. Thank you for the report. For the time being I'm afraid you're going to have to continue using the workaround.

                 

                Bob