3 Replies Latest reply on Apr 12, 2009 3:00 AM by Max Penson

    ShaderJob issues

    FrankPepermans
      I've been experimenting with Pixel Bender lately and came accross the following issues :

      - Only one shader can be executed at a time, when more than one ShaderJob is started, they are automatically queued, however this does not seem to be the case and I had to create an AS3 class which queues the ShaderJobs instead.

      - All ShaderJobs that I start are supposedly asynchronous, and should not slow down the runtime/code execution, but in my tests they did slow down the player significantly, maybe I'm missing something in my code?




      Here's the rather default way I've implemented it :

      shaderJob.addEventListener(ShaderEvent.COMPLETE, onShaderJobComplete);
      shaderJob.start(false);

      and in the onShaderJobComplete function, I simply start the next ShaderJob in my queue

      When continuously firing up ShaderJobs, my framerate plummets to 6 or 7, going to 30 when the queue is empty.

      Thanks for your help
        • 1. ShaderJob issues
          FrankPepermans Level 1
          Update :

          Seems that the slowdown is actually related to the fact that I create a lot of new ShaderJob instances at once.

          The delay occurs when you set the shader property of a ShaderJob instance, this shader has loaded a PBJ and thus contains byteCode, setting a new Shader() without byteCode does not slow down the player.

          >>>
          Note to the above: in my code I just set the byteCode property, I put the 'start()' line in comments, so Pixel Bender is NOT triggered in my test, but the delay does occur and increments even with the more ShaderJobs I create.
          <<<

          Is there any workaround for this? Once a ShaderJob has started, it cannot be reused (throws Error: job has already started...) so keeping ShaderJob instances won't do
          • 2. Re: ShaderJob issues

            After playing with the ShaderJob class, I too think that it should support restarting.

             

            A job instance has to be created every time when shader parameters change which is not good for animations.

             

            ShaderFilter seems to give smoother results.

            • 3. Re: ShaderJob issues
              Max Penson Level 1

              I also couldn't queue Shaderjobs, each time I executed a new job it tramples the Shader parameters of old jobs so only the last job was executed properly. I ended up with a AS queue function...