Multiple aspect ratios alignement - stupeflix
<movie service="craftsman-1.0"> | |
<head> | |
<filtercode name="averageShift"> | |
<![CDATA[ | |
#version 120 | |
#extension GL_EXT_gpu_shader4 : enable | |
uniform sampler2D texture0; | |
uniform sampler2D texture1; | |
uniform sampler2D texture2; | |
vec2 iResolution = vec2(1280, 720.0); | |
float scaleFrom( float coord, float center, float factor ) | |
{ | |
float transformed_coord = coord; | |
transformed_coord -= center; | |
transformed_coord *= factor; | |
transformed_coord += center; | |
return transformed_coord; | |
} | |
float getAspectRatio( in int id ) | |
{ | |
vec2 size = vec2( 1.0 ); | |
if( id == 0 ) { | |
size = textureSize2D( texture0, 0 ); | |
} else if( id == 1 ) { | |
size = textureSize2D( texture1, 0 ); | |
} else if( id == 2 ) { | |
size = textureSize2D( texture2, 0 ); | |
} | |
return size.x / size.y; | |
} | |
vec3 texColor( in int id, in vec2 coord ) { | |
vec3 color = vec3( 0 ); | |
vec2 tc = coord; | |
float a0 = getAspectRatio( 0 ); | |
float at = getAspectRatio( id ); | |
if( id == 0 ) { | |
color = texture2D( texture0, tc / iResolution ).rgb; | |
} else if( id == 1 ) { | |
tc.y = scaleFrom( tc.y, 0.5 * iResolution.y, at/a0 ); | |
color = texture2D( texture1, tc / iResolution ).rgb; | |
} else if( id == 2 ) { | |
tc.y = scaleFrom( tc.y, 0.5 * iResolution.y, at/a0 ); | |
color = texture2D( texture2, tc / iResolution ).rgb; | |
} | |
return color; | |
} | |
void main() { | |
vec2 tc = gl_TexCoord[0].xy * iResolution; | |
vec3 col0 = texColor( 0, tc ); | |
vec3 col1 = texColor( 1, tc ); | |
vec3 col2 = texColor( 2, tc ); | |
gl_FragColor = vec4( 0.3333 * (col0 + col1 + col2 ), 1.0 ); | |
} | |
]]> | |
</filtercode> | |
</head> | |
<body> | |
<stack> | |
<widget type="customers2.xfactor.kaleidoscope.720.01" duration="5"> | |
<video skip="1.0" volume="0" filename="https://s3.amazonaws.com/mixoff.videos.us/f9a138df3e0c2a2db00a1dc2a701d842e73a7b091409671566.mp4"> | |
<filter type="custom"> | |
<filtercode name="averageShift"/> | |
<video volume="0" filename="https://s3.amazonaws.com/mixoff.videos.us/384d6e1da7a0663814f2454136cad85b443fb4041408605850.mp4"/> | |
<video volume="0" filename="http://stupeflix-tmp.s3.amazonaws.com/MVI_2906.MOV.ff.mp4"/> | |
</filter> | |
</video> | |
</widget> | |
</stack> | |
</body> | |
</movie> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment