5 Replies Latest reply on Sep 28, 2009 6:05 AM by krsone21121983

    3d Shadow

    krsone21121983

      Hello,

       

      ist it possibly to create a filter that makes a 3d shadow for a 2d object. (much like this: http://1.bp.blogspot.com/_upWfJMMWOzE/SmUcSwEWiMI/AAAAAAAABpM/Ff3Go1U0JlY/s400/tut7.jpg)?

       

      Is there already a filter that does this available somewhere? Is this kind of shadow really called 3d shadow or should i search for something else?

       

      If there is no filter like this available yet, could anybody give me some hints how to implement this?

       

      thanks for your help

        • 1. Re: 3d Shadow
          WordRad

          In EvaluatePixel, if the input pixel is part of the object being shadowed (i.e. the input pixel is not transparent or not in a designated mask color) you would first draw another another pixel in the designated shadow color at another location, projected down and to the left from the input pixel location via some formula.  Next, you would output the original pixel in its normal location (thus automatically occluding the shadow where the shadow was behind the original object.

           

          if the evaluated pixel is part of the original background,  (i.e. is transparent or a designated mask color) that seems to be a problem.  If there were a way to evaluate pixels in PixelBender in reverse order (right to left, bottom to top) its no problem because any shadow pixel would be drawn over the background.

           

          Well that's the best I personally could come up with at the moment.

           

          Edit: You undoubtedly would have to save an array or vector during rendering to keep track of already drawn pixels so you wouldn't draw over a shadow with a transparent pixel, or part of the object with a shadow pixel.

          • 2. Re: 3d Shadow
            WordRad Level 1

            Just forget the above. Pixel Bender operations may be performed in parallel, so I don't think the above will work.

            • 3. Re: 3d Shadow
              krsone21121983 Level 1

              well thank you for your suggestions so far, but i must admit that i don't really understand what you are saying. could you explain a little further or give me some links with more information?

               

              thanks

              • 4. Re: 3d Shadow
                WordRad Level 1

                You must have even less expertise with graphics then I do, because a solution for it immediately suggested itself (Not to mention the solution of just doing a search on 3-D shadow).  But anyway, as I said, the parallel issue of Pixel Bender isn't dealt with in my proposed solution, but as it stands, I would have hoped it would have been clear what I was suggesting.  Let me walk back through some of it.

                 

                To create this shadow, its just a matter of taking an existing pixel from the object and and then outputting the original pixel where it is, but also another pixel, which will be down and to the left of the original pixel and in some predesignated shadow color. Hopefully that's understandable.  There's some little formula out there presumably that says if your object pixel is at x,y and your light source is whatever, than x',y' is the location of the shadow pixel. If you're not aware, for PixelBender you write a function called EvaluatePixel that all it does is given an input pixel it generates an output pixel.

                 

                But anyway, to determine if an input pixel is part of the object to be shadowed, you would presumably just check its alpha channel, and if its less than 1, then its not transparent so thus part of the object.  So hopefully you know what I'm talking about here.

                 

                But also you would have to consider which type of pixel occludes (is on top of) which other type of pixel, so somehow the drawing order would have to be, 1)background 2)shadow 3)object.

                 

                Well maybe someone with a little more expertise than me might come on and walk you through a more detailed specific solution.

                 

                Good Luck.

                • 5. Re: 3d Shadow
                  krsone21121983 Level 1

                  thanks for the hints. i do not find anything good when searching for 3-d shadow (for example a formula how to calculate it). Do you have any link available?

                   

                  im new to pixelbender. this would be my first filter. I had hoped that a filter like this already existed and I could just use it .