Skip to main content
Participant
April 4, 2025

Using RGBA_F16 for textures not quite right.

  • April 4, 2025
  • 1 reply
  • 381 views

I have no problem creating SceneTexture objects using ARGB_8888 bitmaps, but when I try to use RGBA_F16 the resulting textures are stretched like it is only reading 8-bit data. Here is an example of how I am trying to create an RGBA_F16 bitmap from a W*H buffer (named sdf) of Float's (I am treating these a "gray" values -- i.e. using the same value for RGB and using 1 for alpha):

val sdfBitmap = Bitmap.createBitmap(W, H, Bitmap.Config.RGBA_F16)
val buffer = ByteBuffer.allocate(W*H * 8).order(ByteOrder.nativeOrder())
for (i in sdf.indices) {
    var g16 : Short = Half.toHalf(sdf[i])
    var a16 : Short = Half.toHalf(1.0f)
    buffer.putShort(g16)
    buffer.putShort(g16)
    buffer.putShort(g16)
    buffer.putShort(a16)
}
buffer.rewind()
sdfBitmap.copyPixelsFromBuffer(buffer)

 I am create the texture as follows

val sdfTexture = SceneTexture(sdfBitmap, samplerConfig)

which is later used for SceneMaterial with a custom shader.
Are RGBA_F16 textures supported or am I doing something wrong? Maybe byte order is different?

    This topic has been closed for replies.

    1 reply

    Meta Employee
    April 10, 2025

    Hi!

    We only support ARGB_8888 bitmaps in the current version.