Jump to content

Du/Dv Renders?


ILLUMM

Recommended Posts

You need two images, so it would be a lot easier if Paint.NET allowed plugins to read other layers. You can use the clipboard, kludgy as that is, or in some cases mathematically generate the displacement for each pixel.  Once you have the image you want to distort and the displacement map, use GetBilinearSample to distort the image with the displacements. For example, if the displacements are (somehow) stored in the green and blue channels of the dst image, it would look something like this:

 for (int y = top; y < bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = left; x < right; x++)
        {
            float dX = gradScale * (float)(dst[x, y].G - 127);
            float dY = gradScale * (float)(dst[x, y].B - 127);
            dst[x, y] = src.GetBilinearSample(x + dX, y + dY);
        }
    }
}
Link to comment
Share on other sites

Suppose you want to render the image as if it were reflected in a surface perpendicular to the eye vector. To make it easier, assume the eye vector is a directional vector (the eye point is at infinity). At each pixel there are partial derivatives, Dx and Dy, for the reflecting surface, either computed analytically or from finite differences. For any k, let t = k / (1 - Dx * Dx - Dy * Dy). Then (x', y') = (x - t * Dx, y - t * Dy).

K is half the distance from the reflecting plane to the reflected image. If (1 - Dx * Dx - Dy * Dy) is less than or equal to zero, the reflection vector misses the image plane.

 

(I hope I did the math correctly.)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...