| 1 |
<jittershader name="slide"> |
| 2 |
<param name="slide_up" type="float" default="1" /> |
| 3 |
<param name="slide_down" type="float" default="1" /> |
| 4 |
<param name="tex0" type="int" default="0" /> |
| 5 |
<param name="tex1" type="int" default="1" /> |
| 6 |
<language name="glsl" version="1.0"> |
| 7 |
<bind param="tex0" program="fp" /> |
| 8 |
<bind param="tex1" program="fp" /> |
| 9 |
<bind param="slide_up" program="fp" /> |
| 10 |
<bind param="slide_down" program="fp" /> |
| 11 |
<program name="vp" type="vertex"> |
| 12 |
<![CDATA[ |
| 13 |
// define our varying texture coordinates |
| 14 |
varying vec2 texcoord0; |
| 15 |
varying vec2 texcoord1; |
| 16 |
|
| 17 |
void main(void) |
| 18 |
{ |
| 19 |
// the output vertex postion to the input vertex position |
| 20 |
// transformed by the current ModelViewProjection matrix |
| 21 |
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
| 22 |
|
| 23 |
// assign our varying texture coordinates to the |
| 24 |
// input texture coordinate values transformed |
| 25 |
// by the appropriate texture matrix. This is |
| 26 |
// necessary for rectangular and flipped textures |
| 27 |
texcoord0 = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0); |
| 28 |
texcoord1 = vec2(gl_TextureMatrix[1] * gl_MultiTexCoord1); |
| 29 |
} |
| 30 |
]]> |
| 31 |
</program> |
| 32 |
<program name="fp" type="fragment"> |
| 33 |
<![CDATA[ |
| 34 |
|
| 35 |
uniform float slide_up; |
| 36 |
uniform float slide_down; |
| 37 |
|
| 38 |
varying vec2 texcoord0; |
| 39 |
varying vec2 texcoord1; |
| 40 |
|
| 41 |
uniform sampler2DRect tex0; |
| 42 |
uniform sampler2DRect tex1; |
| 43 |
|
| 44 |
void main(void) |
| 45 |
{ |
| 46 |
vec4 su, sd, up, down, amount; |
| 47 |
|
| 48 |
// sample inputs at texcoords |
| 49 |
vec4 input0 = texture2DRect(tex0, texcoord0); |
| 50 |
vec4 input1 = texture2DRect(tex1, texcoord1); |
| 51 |
|
| 52 |
// get contribution |
| 53 |
amount.x = input0.x > input1.x ? 1.0 : 0.0; |
| 54 |
amount.y = input0.y > input1.y ? 1.0 : 0.0; |
| 55 |
amount.z = input0.z > input1.z ? 1.0 : 0.0; |
| 56 |
amount.w = input0.w > input1.w ? 1.0 : 0.0; |
| 57 |
|
| 58 |
// calculate slide down |
| 59 |
float d = max(1.0, abs(slide_down)); |
| 60 |
sd = vec4(1.0 / d); |
| 61 |
down = input1 + ((input0 - input1) * sd); |
| 62 |
|
| 63 |
// calculate slide up |
| 64 |
float u = max(1.0, abs(slide_up)); |
| 65 |
su = vec4(1.0 / u); |
| 66 |
up = input1 + ((input0 - input1) * su); |
| 67 |
|
| 68 |
// mix between down and up |
| 69 |
gl_FragColor = mix(down, up, amount); |
| 70 |
} |
| 71 |
|
| 72 |
]]> |
| 73 |
</program> |
| 74 |
</language> |
| 75 |
</jittershader> |