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;


              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.drawRect(0, 0, 200, 200);


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


                  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;
                  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.