| 1 |
uniform sampler2D sourceTexture; |
|---|
| 2 |
uniform sampler1D lookupTexture; |
|---|
| 3 |
|
|---|
| 4 |
uniform float minValue; |
|---|
| 5 |
uniform float inverseRange; |
|---|
| 6 |
uniform mat3 filterMatrix; |
|---|
| 7 |
varying vec2 texcoord[9]; |
|---|
| 8 |
|
|---|
| 9 |
uniform float filterBias; |
|---|
| 10 |
|
|---|
| 11 |
#if 1 |
|---|
| 12 |
|
|---|
| 13 |
void main() |
|---|
| 14 |
{ |
|---|
| 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 |
} |
|---|
| 28 |
|
|---|
| 29 |
vec4 overlay_color = texture1D(lookupTexture, (value-minValue)*inverseRange ); |
|---|
| 30 |
|
|---|
| 31 |
gl_FragColor = overlay_color * gl_Color; |
|---|
| 32 |
} |
|---|
| 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 |
|---|