PDA

View Full Version : Interpolation with alpha during texture sampling



Petwoip
10-14-2012, 08:06 PM
My problem is best explained with a picture:
884

By default OpenGL interpolates all four texture channels, which is why the sampled value gets darker. I'm wondering if there is an automatic way to weigh the interpolated color value based on the alpha. So if the left square is (0,0,0,.25) and the right square is (1,0,0,1), the sampled value between the two texels should be (((0,0,0)*.25 + (1,0,0)*1)/(.25+1), (.25+1)/2) = (.8, 0, 0, .625).