#version 150 //OVE shader_name: Displacement //OVE shader_description: by Travis Fischer (Licence MIT) //OVE name: Displacement map //OVE type: TEXTURE //OVE flag: NOT_KEYFRAMABLE //OVE description: uniform sampler2D displacementMap; //OVE name: Strength //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.0 //OVE max: 3.0 //OVE default: 0.5 //OVE description: uniform float strength; //OVE end #define LINEAR_CURVE 0 #define EXPONENTIAL_CURVE 1 #define LOGARITHMIC_CURVE 2 uniform sampler2D out_block_in; uniform sampler2D in_block_in; uniform bool out_block_in_enabled; uniform bool in_block_in_enabled; uniform int curve_in; /* animated from 0 to 1 */ uniform float ove_tprog_all; in vec2 ove_texcoord; out vec4 frag_color; float progress; vec4 getFromColor( vec2 p) { return texture( in_block_in, p); } vec4 getToColor( vec2 p) { return texture( out_block_in, p); } float TransformCurve(float linear) { if (curve_in == EXPONENTIAL_CURVE) { return linear * linear; } else if (curve_in == LOGARITHMIC_CURVE) { return sqrt(linear); } else { return linear; } } vec4 transition (vec2 uv) { float displacement = texture2D(displacementMap, uv).r * strength; vec2 uvFrom = vec2(uv.x + progress * displacement, uv.y); vec2 uvTo = vec2(uv.x - (1.0 - progress) * displacement, uv.y); return mix( getFromColor(uvFrom), getToColor(uvTo), progress ); } void main(void) { progress = TransformCurve(1.0 - ove_tprog_all); frag_color = transition( ove_texcoord.xy); }