Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
waynecochran's avatar
9 months ago

Using RGBA_F16 for textures not quite right.

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?

1 Reply

Replies have been turned off for this discussion
  • dav-s's avatar
    dav-s
    Meta Employee

    Hi!

    We only support ARGB_8888 bitmaps in the current version.