Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup table 256*16 24 bit issue #549

Open
delux-soft opened this issue Jan 31, 2024 · 0 comments
Open

lookup table 256*16 24 bit issue #549

delux-soft opened this issue Jan 31, 2024 · 0 comments

Comments

@delux-soft
Copy link

I write this code for 256*16 table, it works fine with 32-bit color but produce wrong result with 24-bit color.

"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() {" +
" 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) / 1.0);\n" +
" quad1.x = floor(blueColor) - (quad1.y * 16.0);\n" +
" \n" +
" highp vec2 quad2;\n" +
" quad2.y = floor(ceil(blueColor) / 1.0);\n" +
" quad2.x = ceil(blueColor) - (quad2.y * 16.0);\n" +
" \n" +
" highp vec2 texPos1;\n" +
" texPos1.x = (quad1.x * 0.0625) + 0.5/256.0 + ((0.0625 - 1.0/256.0) * textureColor.r);\n" +
" texPos1.y = (quad1.y * 1.0) + 0.5/16.0 + ((1.0 - 1.0/16.0) * textureColor.g);\n" +
" \n" +
" highp vec2 texPos2;\n" +
" texPos2.x = (quad2.x * 0.0625) + 0.5/256.0 + ((0.0625 - 1.0/256.0) * textureColor.r);\n" +
" texPos2.y = (quad2.y * 1.0) + 0.5/16.0 + ((1.0 - 1.0/16.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" +
"}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant