Greyscale texture format in vulkan

1.6k views Asked by At

OpenGL has greyscale texture format: GL_LUMINANCE. What is equivalent of internal format in Vulkan? Or how do we specify greyscale textures in vulkan?

2

There are 2 answers

1
ratchet freak On BEST ANSWER

Take any single channel formats like VK_FORMAT_R8_UNORM for a 8 bit grayscale, VK_FORMAT_R16_SFLOAT for half precision floating point grayscale or VK_FORMAT_R32_SFLOAT for single precision floating point grayscale.

Pick the one that's supported that suits your needs.

0
Columbo On

Ratchet Freak answers the question correctly. But if you're wondering why luminance has gone, there's some rationale from Khronos here in EXT_texture_rg for why Luminance and Luminance-Alpha formats have been replaced in favour of Red and Red-Green formats in modern graphics APIs.

Historically one- and two-component textures have been specified in OpenGL ES using the luminance or luminance-alpha (L/LA) formats. With the advent of programmable shaders and render-to-texture capabilities these legacy formats carry some historical artifacts which are no longer useful.

For example, when sampling from such textures, the luminance values are replicated across the color components. This is no longer necessary with programmable shaders.

It is also desirable to be able to render to one- and two-component format textures using capabilities such as framebuffer objects (FBO), but rendering to L/LA formats is under-specified (specifically how to map R/G/B/A values to L/A texture channels).