4 Replies Latest reply on May 31, 2010 8:33 AM by T Beddard

    Render process in PB graphs

    T Beddard Level 1

      I'm wondering about the rendering process with PB graphs. I've written a few 3d fractal raytracers in PB and I'm wondering if I could improve them by splitting them into two kernels joined in a PB graph.


      The first kernel would calculate the normals for each point in the 3D fractal and pass this through to the second kernel which would apply the shading. I'm wondering that if I only change parameters assigned to the second kernel whether it would re-calculate the entire filter or only the second kernel. If it changes only the second kernel a huge speed boost could be obtained as it would make it very quick to tweak the shading once the normals for the structure had been calculated by the first.


      Also, will the second kernel only execute once the first has finished for all pixels?


      Thanks for any insight.



        • 1. Re: Render process in PB graphs
          Kevin Goldsmith Level 3

          Yes exactly!  If you have a kernel in a graph whose parameters and inputs are unchanging, it's results will be caches from frame to frame, so in your case, the normals would only be computed once and you should see a good speed-up.  If the kernels are wired serially, the second will not execute until the first is completed. This may change in the future if your kernels are point-wise (another reason to make sure your region-reasoning logic is correct!) in that case pixels will only be processed by the second kernel after the first kernel has processed those pixels, but the serialism will be at a much finer grain.       Kevin

          • 2. Re: Render process in PB graphs
            T Beddard Level 1

            Thanks Kevin.


            On a related note, is it possible to have two outputs from a kernel? For each pixel I would like to be able to output a 3 component position vector and 2 element normal vector to a second kernel in the graph that will shade the surface and apply basic screen space ambient occlusion.


            Thanks again


            • 3. Re: Render process in PB graphs
              Kevin Goldsmith Level 3

              Kernels support "fan out" in Pixel Bender Graphs (multiple inputs can be connected to the same output), but not multiple outputs right now. To do this in a Pixel Bender graph normally, you would have two nodes that would execute in parallel one and their results would be passed as inputs to the next nodes.



              something like:





              would that work for you?

              • 4. Re: Render process in PB graphs
                T Beddard Level 1

                Thanks Kevin. In my case the position and normal vectors are dependent on each other and so would have to be calculated in the same kernel.


                I was thinking about another approach. Is it possible to change the route through multiple nodes using a parameter control? For instance I would have an initial kernel setting up the camera view vector for each pixel then the next node would be one of a selection in parallel that would render out different types of fractal. The parameter option would select which of the parallel nodes should be used.

                I've found that trying to put too much in one kernel and using conditional statements can really slow things down, which is why I'd like to split them out.