android-gpuimage icon indicating copy to clipboard operation
android-gpuimage copied to clipboard

how to apply 4*4 LUTS?

Open tyson512 opened this issue 8 years ago • 1 comments

This is very good sample for filters. i need some guidance for LUTS. In this sample you used 8_8 LUT for AMATORKA, based on that i am using different 4_4 LUTs to apply different effects. but results are not correct? if anyone have idea please give your suggestions. please find sample LUT below. http://imgur.com/2taFfP6.

tyson512 avatar Oct 08 '15 11:10 tyson512

You can adjust the 8_8 (64 step) logic to work for 4_4 (16) assuming the 4_4 is 256x256

public static final String LOOKUP_FRAGMENT_SHADER_16 = "varying highp vec2 textureCoordinate;\n" +
        " varying highp vec2 textureCoordinate2; // TODO: This is not used\n" +
        " \n" +
        " uniform sampler2D inputImageTexture;\n" +
        " uniform sampler2D inputImageTexture2; // lookup texture\n" +
        " \n" +
        " uniform lowp float intensity;\n" +
        " \n" +
        " void main()\n" +
        " {\n" +
        "     highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
        "     \n" +
        "     highp float blueColor = textureColor.b * 15.0;\n" +
        "     \n" +
        "     highp vec2 quad1;\n" +
        "     quad1.y = floor(floor(blueColor) / 4.0);\n" +
        "     quad1.x = floor(blueColor) - (quad1.y * 4.0);\n" +
        "     \n" +
        "     highp vec2 quad2;\n" +
        "     quad2.y = floor(ceil(blueColor) / 4.0);\n" +
        "     quad2.x = ceil(blueColor) - (quad2.y * 4.0);\n" +
        "     \n" +
        "     highp vec2 texPos1;\n" +
        "     texPos1.x = (quad1.x * 0.25) + 0.5/256.0 + ((0.25 - 1.0/256.0) * textureColor.r);\n" +
        "     texPos1.y = (quad1.y * 0.25) + 0.5/256.0 + ((0.25 - 1.0/256.0) * textureColor.g);\n" +
        "     \n" +
        "     highp vec2 texPos2;\n" +
        "     texPos2.x = (quad2.x * 0.25) + 0.5/256.0 + ((0.25 - 1.0/256.0) * textureColor.r);\n" +
        "     texPos2.y = (quad2.y * 0.25) + 0.5/256.0 + ((0.25 - 1.0/256.0) * textureColor.g);\n" +
        "     \n" +
        "     lowp vec4 newColor1 = texture2D(inputImageTexture2, texPos1);\n" +
        "     lowp vec4 newColor2 = texture2D(inputImageTexture2, texPos2);\n" +
        "     \n" +
        "     lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n" +
        "     gl_FragColor = mix(textureColor, vec4(newColor.rgb, textureColor.w), intensity);\n" +
        " }";

emitchel avatar Mar 22 '21 12:03 emitchel