MasayukiSuda / GPUVideo-android

This library apply video filter on generate an Mp4 and on ExoPlayer video and Video Recording with Camera2.
MIT License
658 stars 179 forks source link

How to apply 8X8 LUT File #60

Open aahanverma00710 opened 4 years ago

aahanverma00710 commented 4 years ago

I have applied LUT file of 8x8 ratio and in this project they are using 1x16 ration

Do and its not working properly please help if any one have solution for this

StomHong commented 3 years ago

I also want to know

StomHong commented 3 years ago

I have applied LUT file of 8x8 ratio and in this project they are using 1x16 ration

Do and its not working properly please help if any one have solution for this

use this shader:

private final static String FRAGMENT_SHADER = "varying highp vec2 vTextureCoord;\n" + "uniform sampler2D sTexture;\n" + "uniform sampler2D lutTexture;\n" + "void main()\n" + "{\n" + " float lookupDimension = 64.0;\n" + " highp vec4 textureColor = texture2D(sTexture, vTextureCoord);\n" + " highp float blueColor = textureColor.b (lookupDimension - 1.0);\n" + " highp float lookupDimensionSqrt = sqrt(lookupDimension);\n" + " highp vec2 quad1;\n" + " quad1.y = floor(floor(blueColor) / lookupDimensionSqrt);\n" + " quad1.x = floor(blueColor) - (quad1.y lookupDimensionSqrt);\n" + " highp vec2 quad2;\n" + " quad2.y = floor(ceil(blueColor) / lookupDimensionSqrt);\n" + " quad2.x = ceil(blueColor) - (quad2.y lookupDimensionSqrt);\n" + " highp vec2 texPos1;\n" + " texPos1.x = (quad1.x / lookupDimensionSqrt) + 0.5/lookupDimensionSqrt/lookupDimension + ((1.0/lookupDimensionSqrt - 1.0/lookupDimensionSqrt/lookupDimension) textureColor.r);\n" + " texPos1.y = (quad1.y / lookupDimensionSqrt) + 0.5/lookupDimensionSqrt/lookupDimension + ((1.0/lookupDimensionSqrt - 1.0/lookupDimensionSqrt/lookupDimension) textureColor.g);\n" + " highp vec2 texPos2;\n" + " texPos2.x = (quad2.x / lookupDimensionSqrt) + 0.5/lookupDimensionSqrt/lookupDimension + ((1.0/lookupDimensionSqrt - 1.0/lookupDimensionSqrt/lookupDimension) textureColor.r);\n" + " texPos2.y = (quad2.y / lookupDimensionSqrt) + 0.5/lookupDimensionSqrt/lookupDimension + ((1.0/lookupDimensionSqrt - 1.0/lookupDimensionSqrt/lookupDimension) * textureColor.g);\n" + " lowp vec4 newColor1 = texture2D(lutTexture, texPos1);\n" + " lowp vec4 newColor2 = texture2D(lutTexture, texPos2);\n" + " lowp vec4 newColor = vec4(mix(newColor1.rgb, newColor2.rgb, fract(blueColor)), textureColor.w);\n" + " gl_FragColor = mix(textureColor, newColor, textureColor.a);\n" + "}\n";

aahanverma00710 commented 3 years ago

Thanks

milan15440 commented 1 year ago

How can I set intensity of lut filter using this shader