Math 2
|
|

This is the Dmap that we will be working with (for now). It's not much,
but this is about some math that goes along with Displace and a few other
ideas. Once this little ditty is understood, it can easily be extended
to the Green channel as well. And values for Black. And for values inbetween,
as we'll see a little later.
|
|
This is
our test grid. Sure, it's a bit fancy for this, but I like it. Nothing
like a vintage photograph of a ballet dancer with a bunch of lines and
concentric circles. I would like to claim that she was my girlfriend at
one time, but I can't.
It's very important to note that the dimensions of this test grid are
200x200.
|
|
This
is what the Dmap does to our test grid at 100%. Notice that the green
channel in our Dmap is Gray? That means that no matter what percentage
you put in for vertical displacement, no displacement will occur vertically.
Right now we are all about horizontal.
Okay, I did this with Wrap and Repeat Edge Pixels. The darker partion
is what got wrapped with a little help from Layer Transparency.
See how it kind of squishes the picture to the left? Well, it does and
it doesn't. So, how does it work? Glad you asked.
This left edge of the Dmap is White. When Displace tries to find the
new value of the pixel, it wraps around to the left edge and continues
going to the right and finally stops at 128px. As the gradient in the
Dmap fades to Gray, it moves less and less until it takes the same pixel
value at Gray. That's why it squishes. And why the left edge has the same
pixel values. I hope that makes sense.
Now let's try a little reverse engineering. By that I mean make White
take values from a particular pixel down the road.
|
|
We know that
what ever is White in the Dmap will take the value of the pixel this is
128px to the right. That gives us the ratio 100% / 128px.
Let's say we want White to take the value of the pixel 150px to the right.
What's the Mystery Percentage(M%) to accomplish this? Well, just use the
ratios and solve for M%. With a little help from our friendly local calculator,
we get 117%. Not that hard. Now White will take the value of the pixel
150px to the right.
Okay, let's get back to our test grid. We've seen it squish and it's
good. But how do we control it? Let's say we want to squish it to 25%,
or 50px because it's a 200x200 picture. Yeah, that's what we'll do. We'll
squeeze the test grid into the left 50pxs. Sounds good to me.
|
|
First comes
the math. My notes are a bit wrong, but functional. The value 25% of the
way between Gray and White is 160. The displacement is 32px. The amount
we want it to sample from is 150px down the road.
Jeez, what a mess. I'll see about really clarifying this later. For now,
trust me.
Now that we have our Mystery Percentage, it's time to Displace.
|
|
Tada!
Almost perfect. Almost picture perfect. Again, I did it twice and used
Layer Transparency to show it a little better (better in my opinion).
I bet that wasn't as tough as you thought. Maybe it was. I don't know.
I bet it's tough if you don't understand what I'm talking about. It's
not that hard for me to confuse people at times.
Okay, so that was the pure math approach. Now we are going to take a
slightly different one. Why? Because pure math isn't always conducive
to how far you want a value in your Dmap to push things around. So what
we are going to do is use a point sample in the Dmap and go from there.
|
|
Here
we have our Dmap with a dotted line. The dotted line is 25% from the left.
That's where we want to sample from. Once we sample, we can plug some
numbers and get our percentage.
The value I got from the point sample is 156, for a movement value of
28px (156 - 128 = 28).
Time to plug.
|
|
Our Mystery
Percentage is 536%.
Wow! Talk about a far cry from 469%.
Let's try it anyways and see what it does.
|
|
Holy
smokes. We squeezed in 4 repeats and then some. Can you see it? The red
cube in the upper-right hand corner is the beginning of the 5th squish.
So, what kind of difference does this make? Glad you asked.
|
|
Well,
there's the difference between the two. This time I didn't do the Layer
Transparency because it just too messy. The important thing is to note
the difference between one squish and the other.
So, what did we learn? A few things so far, but there is more. We have
yet to explore making a custom Dmap for this application.
If you think real hard, you should be able to visualize what the Dmap
will look like. Or not because I'm going to show two different custom
Dmaps for this. This is our first one.
|
|

The Red Channel has a gradiant the goes from Gray to White in the first
25% of the Dmap. This is the area that we want to squish the image into.
This also means that White has to grab the far left edge, which is 150px
to the right from the 25% mark in the test grid (remember, the test grid
is 200x200). Guess what. We already did the math for this up above. Take
a peek again at the first ratio example. The Mystery Percent is 117%.
|
|
Notice
that the image is left intact from 26% to 100%, or 51px to 200px. That's
because we left that portion of the Dmap Gray!
Waaa-hooo!
With this particular Dmap it doesn't matter if Repeat Edge Pixels is
on or Wrap.
One more quick example, except this time that Gray part in the Red channel
will be White.
|
|

There we go. Man, talk about ugly. Ready to Displace again? Good.
|
|
Remember,
117%. Wow. That's ugly, too. Repeat Edge Pixels was on and it left that
ugly banding. Yech. Wonder why? Must be a bug of some sort.
I got an idea. Let's try it with Wrap.
This is the last time. I promise.
|
|
Can you
figure out why it looks like that? I hope so. I has to do with the solid
White in thet 26%-100% range of the Dmap. So we got some appropriate squish
and a picture kind of sliding in.
Now we can sit back, relax, and let it soak in.
|
Addendum: In the above discussion, there are two mistakes:
the numbers are as perfect as they should be, and the banding. Turns out
the numbers aren't quite right because of Smoothness: 100% when I laid down
the gradients in the D-Map. This has caused some of the numbers to be off
by a bit. In particular, the example of sampling a colour from the D-Map.
And it turns out that the banding is caused by Interpolation. In the example
with
banding,
Interpolation
was
set to
Bi-Linear.
Had it been
set to Nearest Neighbor, there wouldn't be any banding. Try it for yourself
as an exercise. |
| |