我想对使用opengl 2.0的android做一个鱼眼效果,我可以不使用opengl,但这不是我想要的,因为这是低效的,不支持视频纹理。我还使用Android Media Effects API测试鱼眼效果,但效果看起来不太好。
我还搜索fishshader如下:
private static final String FISHEYE_FRAGMENT_SHADER =
"precision mediump float;\n" +
"uniform sampler2D u_Texture;\n" +
"uniform vec2 vScale;\n" +
"const float alpha = float(4.0 * 2.0 + 0.75);\n" +
"varying vec2 v_TexCoordinate;\n" +
"void main() {\n" +
" float bound2 = 0.25 * (vScale.x * vScale.x + vScale.y * vScale.y);\n" +
" float bound = sqrt(bound2);\n" +
" float radius = 1.15 * bound;\n" +
" float radius2 = radius * radius;\n" +
" float max_radian = 0.5 * 3.14159265 - atan(alpha / bound * sqrt(radius2 - bound2));\n" +
" float factor = bound / max_radian;\n" +
" float m_pi_2 = 1.570963;\n" +
" vec2 coord = v_TexCoordinate - vec2(0.5, 0.5);\n" +
" float dist = length(coord * vScale);\n" +
" float radian = m_pi_2 - atan(alpha * sqrt(radius2 - dist * dist), dist);\n" +
" float scalar = radian * factor / dist;\n" +
" vec2 new_coord = coord * scalar + vec2(0.5, 0.5);\n" +
" gl_FragColor = texture2D(u_Texture, new_coord);\n" +
"}\n";
这是我想要的,但我不知道如何使用它。可以有人给我一些线索。
答案 0 :(得分:0)
Android OpenGL ES(通常)支持视频纹理。它不是OpenGL ES API的严格组成部分,但您通常可以通过Android SurfaceViews将视频表面导入为EGL外部图像。
网上有很多类似的问题,但这个问题应该提供一个有用的起点: