Skip to content

lookup table 256*16 24 bit issue #549

@delux-soft

Description

@delux-soft

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" +
"}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions