2016-08-18 120 views
0

我想做一個android使用opengl 2.0的魚眼效果,我可以做到不使用opengl,但這不是我想要的,因爲這是效率低下,不支持視頻紋理。我還使用Android Media Effects API測試魚眼效果,但效果看起來不太好。魚眼效果使用opengles

我也搜索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"; 

這是我想要的,但我知道DONOT如何使用它。可有人給我一些線索。

回答

0

Android OpenGL ES確實(通常)支持視頻紋理。它不是OpenGL ES API的嚴格組成部分,但通常您可以通過Android SurfaceViews將視頻表面作爲EGL外部圖像導入。

有很多在網絡上類似的問題,但是這太問題應該提供一個有用的起點:

Android. How play video on Surface(OpenGL)