I am trying to shade a surface with a sequence of colors to achieve certain visual effects. One effect is a gradient from one color to another. Assume I have a lookup texture with a black and a white texel. I apply the colors to the whole surface by selecting [0,1] of the color sequence. Linear interpolation creates a nice gradient. Now I want to repeat that sequence. Intuitively I would like to use a range of [0,2] and the gradient should be drawn twice along the surface.
But that creates a hard edge in the middle because each gradient takes up 50% of the surface. (a general issue, not GL specific) I could squeeze in a "hidden" texel and use some additional space to interpolate between the last and first color of the sequence. But then the scaling becomes ugly. A sequence applied to [0,1] along the surface would be slightly more than twice as long as each of the repeated sequences applied to [0,2].
Another effect is a repeated pattern to create stripes. There I do not need additional space between repeated sequences. E.g. a surface with b,w,b,w stripe shading would be broken if I squeeze anything between the first and second b,w sequence.
If I repeat b,w to b,w,b,w I get working stripes with NN but the hard edge in the middle for gradients. If I repeat b,w,b to b,w,b,b,w,b it works with linear ip but NN messes up the size of the stripes.
So it looks like I have to make sure that a color sequence starts and ends with the same color, if i want a smooth repetition. And I have to switch interpolation behaviour (call GL or manually interpolate in shader) if I want to create distinguishable stripes instead of gradients?
Can somebody wrap their head around all that and tell me if i am on the right track or missing something. Feeling a bit in the dark right now.
Repeat a color scale along a surface with interpolation
124 Views Asked by J-S At
0