辛苦老师帮忙解答下原因:
将两个不同尺寸的视频拼接在一起,在surfaceview展示视频的时候首先经过正交投影等处理之后,再添加转场特效,最终展现的效果是,两个片段尺寸相同的正常展示转场特效,如果不相同就会变成缩放的特效,shader的脚本如下:
#define TRANSITION_VERTEX_SHADER_SOURCE R"(#version 320 es
layout (location = 0) in vec4 aPosition;
layout (location = 1) in vec2 aTexCoord;
out vec2 vTexCoord;
uniform mat4 uMVPMatrix1;
uniform mat4 uMVPMatrix2;
uniform float uProgress1;
void main() {
vec4 pos1 = uMVPMatrix1 * aPosition;
vec4 pos2 = uMVPMatrix2 * aPosition;
gl_Position = mix(pos1, pos2, smoothstep(0.0, 1.0, uProgress1));
vTexCoord = aTexCoord;
}
)"
#define TRANSITION_FRAGMENT_SHADER_SOURCE R"(#version 320 es
precision mediump float;
in vec2 vTexCoord;
out vec4 FragColor;
uniform sampler2D uLastTexture;
uniform sampler2D uNextTexture;
uniform float uProgress;
void main() {
vec4 lastColor = texture(uLastTexture, vTexCoord);
vec4 nextColor = texture(uNextTexture, vTexCoord);
// 使用更明显的混合效果
FragColor = mix(lastColor, nextColor, smoothstep(0.0, 1.0, uProgress));
}
)"
这是个淡入淡出的转场特效