6 Replies Latest reply on Sep 14, 2010 4:00 AM by Malikiel

    cast between types



      I am new to pixel bender. I am a CG artist with a very little developper background...

      I understand pixel bender language is strongly typed. OK fine....

      But i would like to understand the difference between

      (for instance)

      dst.a  = float(0.0);


      dst.a = pixel1(0.0);


      Am i free to write both syntaxes. Indeed both run without exceptions in my very simple sample script.

      Regarding memory usage or efficiency, what is the true difference between theses two types



      i understand pixel4 is a kind of convention for output. Like image4 for input. Ok Fine.

      But pixel4(0.0) == float4(0.0); returns true

      so, i would like to understand the true meanings of theses types to build effectives pixel bender fragments

      I am sorry but english is not my native bytecode

      hope you understand what i mean


      thanks for clues




        • 1. Re: cast between types
          Malikiel Level 1

          in fact, i don't understand the true difference between pixel and float values..

          So why pixel bender makes differences between theses types ?

          If pixel bender is strongly typed, i am sure there is a big difference. But without real time debugger, it is pretty difficult for me to see it.

          Maybe pixel are unsigned ?



          • 2. Re: cast between types
            Royi A Level 1

            At the beginning I thought pixel type means always casting into [0 1] while float isn't clipped.

            Yet, if you look for it on the forum, There is no difference between pixel and float in PB at the moment.

            They had ideas at the beginning how pixel should be different, however they never made it.

            1 person found this helpful
            • 3. Re: cast between types
              Malikiel Level 1

              Thanks Royi A

              So i will use pixel values when it makes sense for anyone who read my code.

              And i will use float values for arithmetics purposes.

              Thanks for your reply. really ^^ I was not sure....


              To describe the background, i am trying a PB to remap texture on CG render. It requires 2 inputs, the uv channel and the texture. The uv channel is a special map rendered with cg soft (maya, max, xsi, etc.) where uv space is mapped in the 32 bits u(0.0 , 1.0) v(0.0 , 1.0) space

              where red channel stands for u

              green channel stands for v

              bleu channel stands for pixel coverage between geometry

              alpha stands for cropping and acceleration structure.


              To tell things speedy (frenchy syntax) : i query the uv map to retrieve the alpha, blue, red and green channels, then i sample the second input (the texture to remap) to write output accordingly. In fact i come from uv space to screen space mapping.

              Because the result is very aliased, i use (actually) a graph to propagate output to a fragment for B-spline super sampling.


              That is, the super sampling is done after transformations. It is a screen space super sampling. it is not ideal :/  but i don't know how to deal with super sampling before transformations with keeping "full pixel datas" ... :/  I don't know how to keep track of image4 pixels... because of paralellism of evaluatepixel()


              I publish parameters to select nodeRenderID, offset and tile texture onto the geometry. Actually the filter needs to be applied several time to remap serveral geometry on a single picture (based on renderID)


              In fact this filter is similar to autodesk combustion 3D-texmap operator with screen space mitchell-netravali sampling. If you see what i mean... ^^


              I don't do it for fun, i do it because my customer needs to remap his customer's picture on CG product-render in real time with flash. I hope my PB will export to pbj regarding limitations ; graph not allowed :$  I will deal with it later. One thing at a time.

              I will try 2 filters in pipeline.... well really i don't know if PB is my solution. lot of work to be done !! ^^ But i try it !! Hope it helps. I can't do it in ActionScript without heavy payload on customer's cpu. That's why i try PB


              If i can achieve the result I will distribute it for free on adobe exchange when it's done : A texmap filter with screen space anti aliasing for flash and toshop as least


              again, excuse me for my frenchy bytecode



              • 4. Re: cast between types
                Royi A Level 1

                That's the logic I use.

                If it's a calculation of a pixel (Meaning assuming Domain and Range in [0 1]) I use pixel type.

                If it's an auxiliary calculation I use float.


                Sorry, I don't have much knowledge in Computer Graphics.

                My knowledge in in the Image Processing world.


                Wish you success with your code.

                • 5. Re: cast between types
                  Kevin Goldsmith Level 3

                  Royi was correct. float and pixel are interchangeable. I think the idea of using pixel for output values and float for computation values is a good convention. I may recommend that in the future.

                  1 person found this helpful
                  • 6. Re: cast between types
                    Malikiel Level 1



                    just to edit my previous post, of course i wanted to write "maybe float are unsigned" not pixel ^^


                    PB are very fun to work with. ^^