Pergunta

I have an art pipeline, which includes following steps:

Normal map is generated. I want to save only X and Y components as unsigned bytes. Z is omitted because it is reconstructed in pixel shader.

Normal map is saved to an intermediate image file which is then fed to nvtt to compress it to BC5.

To save the normal map I need to use Windows Imaging Component. Which format should I use to store the intermediate image?

.png with any of the available 16bpp formats fails (GUID_WICPixelFormat16bppBGR565, 555, 5551, Gray, GrayFixedPoint, GrayHalf).

.bmp succeeds e.g. GUID_WICPixelFormat16bppBGR565 but then nvtt can't load it.

Normal maps I've seen so far are usually blue with shades of red. Are those 24bpp images or 16bpp images? Then which component is removed (G?) and in what format are they passed to nvtt?

Because it somehow makes no sense to write an image with only 2 color channels in a way as if it had 3 color channels as BGR565 (or gray only, if 16bppGray is used). BC5 is lossless and shouldn't mess the image up, but the intermediate file will be useless for any manual editing later.

Foi útil?

Solução

Ok, a friend suggested the solution. BC5 expects BGRA format, 8bit per color.

B and A should be set to 0. X component of the normal goes into R, Z goes into G, and Y (height) is omitted.

The pixel shader gets X in [0] and z in [1] components of the result of Sample call.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top