Dear All,
Here is a version that accepts a displace amount from 0 to 100 and an angle between 0 and 360.
/*
a Displace Shader Actor
proposed by Jacques Hoepffner
after isadora Werkstatt 2017
updated by Mark Coniglio to move the pixels based
on an a displace amount and an angle instead of
separate x/y inputs
this version also calculates the actual greyscale
brightness of the pixel using standard a conversion
algorithm
Note that this code will not produce the same results
as the built-in Isadora Displace actor.
*/
// greyscale weights for RGB to gray conversion
const vec4 sGrayScaleWeights = vec4(0.3086, 0.6094, 0.0820, 0.0);
// used to convert from degrees to radians
const float sDegreesToRadians = 0.01745329252;
// 2 texture inputs
uniform sampler2D tex0;
uniform sampler2D tex1;
// ISADORA_FLOAT_PARAM(amount, amtt, 0.0, 100.0, 50.0, "Displace amount.");
uniform float amount;
// ISADORA_FLOAT_PARAM(angle, angl, 0.0, 360.0, 0.0, "Displace angle");
uniform float angle;
void main(void) {
float radians = (angle/360.0) * sDegreesToRadians;
vec2 offset_max = vec2( (sin(radians) + 1.0) / 2.0, (cos(radians) + 1.0) / 2.0 );
// displace tex0 pixels, according to the brightness of tex1 pixels
vec4 c1 = texture2D(tex1, gl_TexCoord[0].st);
vec4 greyColor = c1 * sGrayScaleWeights;
float luminance = greyColor.r + greyColor.g + greyColor.b;
vec2 src_coord = gl_TexCoord[0].st + offset_max * luminance * (amount/100.0);
vec4 color = texture2D(tex0, src_coord);
gl_FragColor = color;
}