1 Reply Latest reply on Sep 22, 2009 12:47 AM by Kevin Goldsmith

    Simple PB Kernel not displaying anything in flash.

    mr_malee Level 1

      Take this Kernel:

       

      <languageVersion : 1.0;>

       

      kernel NewFilter
      <   namespace : "Your Namespace";
          vendor : "Your Vendor";
          version : 1;
          description : "your description";
      >
      {
          input image4 background;
          input image4 foreground;
          output pixel4 dst;

       

          void
          evaluatePixel()
          {
              dst = sampleNearest(foreground,outCoord());
          }
      }

       

      it takes the foreground and simple sets that as the output, everything works fine in the toolkit preview. Now go into flash and using this simple code:

       

      package {
         
          import flash.display.*;
          import flash.events.*;
          import flash.net.*;
          import flash.utils.*;
         
          public class Main extends Sprite {
             
              private var gfx:Shape;
              private var shader:Shader;
              private var loader:URLLoader;
             
              public function Main() {
                 
                  graphics.beginFill(0x00FF00);
                  graphics.drawRect(0, 0, 200, 200);
                  graphics.endFill();

       

                  gfx = new Shape();
                  gfx.graphics.beginFill(0xFF0000);
                  gfx.graphics.drawCircle(0, 0, 100);
                  gfx.graphics.endFill();     

       

                  loader = new URLLoader();
                  loader.dataFormat = URLLoaderDataFormat.BINARY;
                  loader.addEventListener(Event.COMPLETE, onShaderLoaded);
                  loader.load(new URLRequest("filter.pbj"));
              }
             
              function onShaderLoaded(event:Event):void {
                 
                  shader = new Shader(loader.data);
                 
                  gfx.blendShader = shader;
                 
                  addChild(gfx);
                 
                  addEventListener(Event.ENTER_FRAME, onMain);
              }
             
              function onMain(event:Event):void {
                 
                  gfx.x = mouseX;
                  gfx.y = mouseY;
              }
          }
      }

       

      which simply draws a red circle and moves it to the mouse position.

       

      Why is the sahder not showing the red circle? This has completly baffeled me. I just want the same output as the input.

       

      I've attached the source files, CS4.

       

      Thanks for any help.