Results 1 to 6 of 6

Thread: Graphics Effect Math

  1. #1
    NOMADMAN
    Guest

    Graphics Effect Math

    How would you make a bubble lens effect, like looking through a fish-eye lens.
    I wanted to know the equations behind the pixel color translations. Anyone know where I can find this? Or have any examples?

  2. #2
    Zaei
    Guest
    My internet died as I was posting a reply to this message last night.
    First, you need to know the equation of a parabola. Using this, you can define your "lens" as a parabola. Then, for each x coordinate, find the y value that is on the parabola for that coordinate. Then, at that point, find the slope of the parabola (probably calculus here), and find a line that goes perpendicular the the slope. Using that, extend that line until it hits the source image. The pixel you intersect is the pixel to plot. Here is an Image:



    Z.
    Attached Images Attached Images  

  3. #3
    NOMADMAN
    Guest
    ahh, so simple. Very Nice Z! Thanks.

    So I'm guessing that this would also work with other equations suck as low amplitude sine/cosine curves. Hmm, that would be an interesting project. Well if I ever finish the project I'll be sure to post it here!

    Thanks again!

    NOMAD

  4. #4
    Zaei
    Guest
    I forgot to mention =). All of that was out of my own head, so you may want to do a bit more research, but it seems pretty sound to me. Points nearest the center of the image will come out close to the original, while ones nearest the edge will be distorted.

    Z.

  5. #5
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    Damn you and your college-level education, zaei!

    Btw, there's a very very fast way to apply effects like that... but if I tell you how, my friend who invented the trick will kill me
    "1 4m 4 1337 #4xz0r!'
    Janus

  6. #6
    Zaei
    Guest
    You need to add 128 to j in the call to GetPixel(). Also, since squaring any value will give you a positive value, you need to determine if the pixel you should be getting is negative or positive.

    Z.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width