0

android-gpuimageライブラリで使用しているフィルターをMediacodecサーフェス コンテキストに適用しようとしています。これまでのところ、余分なテクスチャ マップを 1 つだけ必要とするフィルターを使用することに成功しました。ただし、少なくとも 2 つ必要なフィルターを適用しようとすると、結果は青色または虹色の混乱になります。

次の問題は、テクスチャ ルックアップ フィルターとビネット フィルターを使用する問題を扱います。

使用した頂点シェーダーは次のとおりです。

uniform mat4 uMVPMatrix;
uniform mat4 textureTransform;

attribute vec4 vPosition;
attribute vec4 vTexCoordinate;

varying vec2 v_TexCoordinate;

void main() {
    gl_Position = uMVPMatrix * vPosition;
    v_TexCoordinate = (textureTransform * vTexCoordinate).xy;
}

使用したフラグメント シェーダーは次のとおりです。

#extension GL_OES_EGL_image_external : require

precision lowp float;

varying highp vec2 v_TexCoordinate;

uniform samplerExternalOES u_Texture; //MediaCodec decoder provided data
uniform sampler2D inputImageTexture2; //Amaro filter map
uniform sampler2D inputImageTexture3; //Common vignette map

void main()
{
    vec3 texel = texture2D(u_Texture, v_TexCoordinate).rgb;

    vec2 red = vec2(texel.r, 0.16666);
    vec2 green = vec2(texel.g, 0.5);
    vec2 blue = vec2(texel.b, 0.83333);

    texel.rgb = vec3(
                     texture2D(inputImageTexture2, red).r,
                     texture2D(inputImageTexture2, green).g,
                     texture2D(inputImageTexture2, blue).b);

    //After further research I found the problem is somewhere below
    vec2 tc = (2.0 * v_TexCoordinate) - 1.0;
    float d = dot(tc, tc);
    vec2 lookup = vec2(d, texel.r);
    texel.r = texture2D(inputImageTexture3, lookup).r;
    lookup.y = texel.g;
    texel.g = texture2D(inputImageTexture3, lookup).g;
    lookup.y = texel.b;
    texel.b = texture2D(inputImageTexture3, lookup).b;
    //The problem is somewhere above

    gl_FragColor = vec4(texel, 1.0);
}

そのプログラムの最終結果は次のようになりました。 結果のビデオ - 一時停止

これは悪いビネット マップの結果ですか、それともフラグメント シェーダーのビネット アプリケーション部分と関係がありますか?

編集:

inputImageTexture2 に使用されるテクスチャ:

lomo_map

inputImageTexture3 に使用されるテクスチャ:

ここに画像の説明を入力

4

1 に答える 1