3 Replies Latest reply on Dec 14, 2011 10:06 AM by AIF Bob

Hi all, this forum has been a huge help to me in creating pb plugins so first of all thanks for the help so far.
But I have come to a point where I may now have to ask some specific questions.

I'm trying to create a 4 point linear gradient as opposed to a radial effect such as the built in 4 point.

I've tried a couple methods but no luck:

1. Took the four colors of the corners and averaged them based on weighted distance from the sample coordinate to each corner. It didn't quite give the right effect.

2. Next I tried a kind of crack head approach that calculated gradients from each of the top verts to each bottom one. (4 gradients) I then weighted mixed them based on the distance from the sample point to the closest part of each gradient line.

3. Various other methods and variations of 1 and 2.

Also, something I want to avoid: When I tried corner pinning a ramp brainstorming the look of the effect, values pinched where the points got closer together. I'm afraid this might still happen even if I find the optimum solution, honestly I don't know what to expect. I'm told what I'm trying to replicate is like shake's 4 point node if that helps but I do not know from experience.

Also, I do not need to deal with color. If someone does have an explanation and it would be easier to explain without talking about mixing colors, that will be fine.

Thanks for any help with this!

 Dang. Didn't mean to post in the 3d section. This might not be the right place. Would a moderator be able to move this if it's wrong?

• ###### 1. Re: 4 point linear gradient

I don't think I can move the question I'm afraid.

Can you post some images that show what it is you're trying to achieve, and what you're actually getting. If I was asked to produce a 4 point gradient I'd probably go for something like your solution #1, but without an image I can't tell why it isn't the look you're after.

Bob

• ###### 2. Re: 4 point linear gradient

Didn't realize anyone replied to this...

Here's an image of what I'm trying to achieve:

From what I'm reading, I should apparently inverse a bilinear interpolation equation. The math itself is proving to be difficult, much less incorporating it into pixel bender. Any thoughts?

• ###### 3. Re: 4 point linear gradient

I did some searching and came up with a couple of web pages that talk about this problem and include code:

http://stackoverflow.com/questions/808441/inverse-bilinear-interpolation

http://www.iquilezles.org/www/articles/ibilinear/ibilinear.htm

I hope these help.

Bob