From 80e2fc59508fc869c4b1cde0d92ba1408452f3c1 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 30 Oct 2024 16:23:37 +0200 Subject: [PATCH] EXR: more standard RGBA channel name detection Various EXR images especially from movie assets do not simply have "R" etc as channel names; the convention seems to be to have "layer name", ".", "color channel name". For example, channels in EXR might be "rgb.R", "rgb.G", "rgb.B", which RenderDoc was not detecting previously and displaying an all-black image. --- renderdoc/core/image_viewer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/renderdoc/core/image_viewer.cpp b/renderdoc/core/image_viewer.cpp index 3b32512e21..409b1b3d14 100644 --- a/renderdoc/core/image_viewer.cpp +++ b/renderdoc/core/image_viewer.cpp @@ -758,10 +758,14 @@ void ImageViewer::RefreshFile() return; } + // Expect R/G/B/A channel names as first char of the string, or + // after the last '.' char. int channels[4] = {-1, -1, -1, -1}; for(int i = 0; i < exrImage.num_channels; i++) { - switch(exrHeader.channels[i].name[0]) + const char* dotPos = strrchr(exrHeader.channels[i].name, '.'); + const char *name = dotPos ? dotPos + 1 : exrHeader.channels[i].name; + switch(name[0]) { case 'R': channels[0] = i; break; case 'G': channels[1] = i; break;