Hi,
I'm trying to display 16bits grayscale image through GLSL.
I also found good source codes(Scene Graph - Graph) in the Qt 5.14 examples.
Just like the Noise node, I would like to put the 16bits grayscale image instead of the RGB image.
So, I put the 16bits fixed values in the QImage and then I tried to read the texture values in the fragment shader.
But the shader always gets 8bits value only.

Does anyone know how to read 16bits value in the shader?

// [GEOMETRY]
QSGGeometry *geometryPtr = new QSGGeometry(QSGGeometry::defaultAttributes_Texture dPoint2D(), 4);
QSGGeometry::updateTexturedRectGeometry(geometryPt r, QRect(), QRect());

setGeometry(geometryPtr);
setFlag(QSGNode::OwnsGeometry, true);

// [MATERIAL]
QSGTexture *textureImage =nullptr;
{
// draw demo image(the grayscale image should be equalized)
int width = 10;
int height = 10;

QImage image = QImage(width, height, QImage::Format_Grayscale16);
{
ushort *dstDataPtr = reinterpret_cast<ushort*>(image.bits());
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
if(y < 3)
dstDataPtr[y*width+x] = 0xFA7C;
else if(y < 6)
dstDataPtr[y*width+x] = 0xFFFF;
else
dstDataPtr[y*width+x] = 0xFAF1;
}
}
}

textureImage = window->createTextureFromImage(image);
textureImage->setFiltering(QSGTexture::None);

qDebug() << image.pixelColor(0, 0) << ", my value: " << 0xFA7C / 65535.0; // QColor(ARGB 1, 0.97847, 0.97847, 0.97847), my value: 0.97847
}

// texture to material
QSGSimpleMaterial<ProcImageMaterial> *materialPtr = ProcImageShader::createMaterial();
materialPtr->state()->texture = textureImage;

setMaterial(materialPtr);
setFlag(QSGNode::OwnsMaterial, true);

///////////////////
fragment shader
//////////////////

varying highp vec2 qt_TexCoord0;

uniform highp sampler2D texture;
uniform lowp float qt_Opacity;

void main() {
vec4 pixelColor = texture2D(texture, qt_TexCoord0);
int pixelValue16 = int(floor(pixelColor.r * 65535.0 + 0.5));
if(pixelValue16 == 0xFA7C)
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * qt_Opacity;
else if(pixelValue16 == 0xFAFA)
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0) * qt_Opacity;
else
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0) * qt_Opacity;
}