| 11 | | float value = 0.0; |
|---|
| 12 | | value += texture2D(sourceTexture, texcoord[0].xy).x * filterMatrix[0][0]; |
|---|
| 13 | | value += texture2D(sourceTexture, texcoord[1].xy).x * filterMatrix[0][1]; |
|---|
| 14 | | value += texture2D(sourceTexture, texcoord[2].xy).x * filterMatrix[0][2]; |
|---|
| 15 | | value += texture2D(sourceTexture, texcoord[3].xy).x * filterMatrix[1][0]; |
|---|
| 16 | | value += texture2D(sourceTexture, texcoord[4].xy).x * filterMatrix[1][1]; |
|---|
| 17 | | value += texture2D(sourceTexture, texcoord[5].xy).x * filterMatrix[1][2]; |
|---|
| 18 | | value += texture2D(sourceTexture, texcoord[6].xy).x * filterMatrix[2][0]; |
|---|
| 19 | | value += texture2D(sourceTexture, texcoord[7].xy).x * filterMatrix[2][1]; |
|---|
| 20 | | value += texture2D(sourceTexture, texcoord[8].xy).x * filterMatrix[2][2]; |
|---|
| | 15 | float value_0 = 0.0; |
|---|
| | 16 | float original_value = texture2D(sourceTexture, texcoord[4].xy, 0.0).x; |
|---|
| | 17 | float max_delta = 0.01; |
|---|
| | 18 | float value = original_value; |
|---|
| | 19 | float minBias = 0.5; |
|---|
| | 20 | float maxBias = 2.5; |
|---|
| | 21 | float deltaBias = 0.5; |
|---|
| | 22 | for(float bias = minBias; bias<filterBias; bias += deltaBias) |
|---|
| | 23 | { |
|---|
| | 24 | float new_value = texture2D(sourceTexture, texcoord[4].xy, bias).x; |
|---|
| | 25 | if (abs(new_value-original_value) > max_delta) break; |
|---|
| | 26 | value = new_value; |
|---|
| | 27 | } |
|---|
| | 33 | |
|---|
| | 34 | #else |
|---|
| | 35 | |
|---|
| | 36 | void main() |
|---|
| | 37 | { |
|---|
| | 38 | float bias = filterBias; |
|---|
| | 39 | |
|---|
| | 40 | float value = 0.0; |
|---|
| | 41 | value += texture2D(sourceTexture, texcoord[0].xy, bias).x * filterMatrix[0][0]; |
|---|
| | 42 | value += texture2D(sourceTexture, texcoord[1].xy, bias).x * filterMatrix[0][1]; |
|---|
| | 43 | value += texture2D(sourceTexture, texcoord[2].xy, bias).x * filterMatrix[0][2]; |
|---|
| | 44 | value += texture2D(sourceTexture, texcoord[3].xy, bias).x * filterMatrix[1][0]; |
|---|
| | 45 | value += texture2D(sourceTexture, texcoord[4].xy, bias).x * filterMatrix[1][1]; |
|---|
| | 46 | value += texture2D(sourceTexture, texcoord[5].xy, bias).x * filterMatrix[1][2]; |
|---|
| | 47 | value += texture2D(sourceTexture, texcoord[6].xy, bias).x * filterMatrix[2][0]; |
|---|
| | 48 | value += texture2D(sourceTexture, texcoord[7].xy, bias).x * filterMatrix[2][1]; |
|---|
| | 49 | value += texture2D(sourceTexture, texcoord[8].xy, bias).x * filterMatrix[2][2]; |
|---|
| | 50 | |
|---|
| | 51 | vec4 overlay_color = texture1D(lookupTexture, (value-minValue)*inverseRange ); |
|---|
| | 52 | |
|---|
| | 53 | gl_FragColor = overlay_color * gl_Color; |
|---|
| | 54 | } |
|---|
| | 55 | #endif |
|---|